I have a Grid defined in an ItemsControl ItemsPanelTemplate, and one of RowDefinitions has a x:Name defined (so I could animate the row size).
<ItemsControl ItemsSource="{Binding Data, Source={StaticResource model}}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<Grid>
<Grid.RowDefinitions>
<RowDefinition x:Name="t" />
<RowDefinition />
</Grid.RowDefinitions>
</Grid>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
This worked fine in 3.5, however when we recently upgraded to 4.0 it all fell apart. What I would see is a Grid with the defined Row and Column definitions but no children.
If I set IsItemsHost=true on the Grid, everything starts working. If I add an x:Name to the Grid itself, or remove the x:Name from the RowDefinition it all works.
<ItemsPanelTemplate>
<Grid IsItemsHost="True">
<Grid.RowDefinitions>
<RowDefinition x:Name="t" />
<RowDefinition />
</Grid.RowDefinitions>
</Grid>
</ItemsPanelTemplate>
or
<ItemsPanelTemplate>
<Grid x:Name="g">
<Grid.RowDefinitions>
<RowDefinition x:Name="t" />
<RowDefinition />
</Grid.RowDefinitions>
</Grid>
</ItemsPanelTemplate>
This seems like a bug, but I wanted to check with the community and see if people agreed, or if I've overlooked something. I could not find anything on Connect or the web, so can anyone explain what I'm seeing?
Grid
as well and you're good to go – ExcursusIsItmemsHost="True"
affects the behaviour of items generation inItemsControl
and should be considered a must in anyItemsPanelTemplate
. As to whyx:Name
affects the behaviour - I'm still baffled by that one.... – Foreandaft