我在 ItemsControl ItemsPanelTemplate 中定义了一个网格,并且其中一个 RowDefinitions 定义了 ax:Name(因此我可以为行大小设置动画)。
<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>
这在 3.5 中运行良好,但是当我们最近升级到 4.0 时,一切都崩溃了。我会看到一个定义了行和列定义但没有子级的网格。
如果我在网格上设置 IsItemsHost=true,一切都会开始工作。如果我将 x:Name 添加到 Grid 本身,或者从 RowDefinition 中删除 x:Name ,则一切正常。
<ItemsPanelTemplate>
<Grid IsItemsHost="True">
<Grid.RowDefinitions>
<RowDefinition x:Name="t" />
<RowDefinition />
</Grid.RowDefinitions>
</Grid>
</ItemsPanelTemplate>
或者
<ItemsPanelTemplate>
<Grid x:Name="g">
<Grid.RowDefinitions>
<RowDefinition x:Name="t" />
<RowDefinition />
</Grid.RowDefinitions>
</Grid>
</ItemsPanelTemplate>
这似乎是一个错误,但我想与社区核实一下,看看人们是否同意,或者我是否忽略了一些东西。我在 Connect 或网络上找不到任何东西,所以任何人都可以解释我所看到的吗?