Making the items in a WPF ItemsControl stretch

I used the layout I described in a previous post in a Prism-based application where I used "ItemsControl" objects for regions, and the views I attached to them didn't stretch to fill the ItemsControl.

After some research I found the following solution: replace the default items panel template with a DockPanel.

Here's the code:

<ItemsControl 
  Name="MainRegion" 
  cal:RegionManager.RegionName="{x:Static common:RegionNames.Main}"
  Grid.Column="2" Grid.Row="1">
  <ItemsControl.ItemsPanel>
    <ItemsPanelTemplate>
      <DockPanel />
    </ItemsPanelTemplate>
  </ItemsControl.ItemsPanel>
</ItemsControl>

Comments

Popular posts from this blog

Restart the Windows File Sharing Service to fix weird problems

WPF, ImageSource and Embedded Resources

SharpDevelop dark color scheme