Elentok's Blog

About me

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>
Next:How to use your iPod Touch as an alarm clock