Tho*_*que 22
使用ItemsControl带有ItemsPanel网格的集合:
<ItemsControl ItemsSource="{Binding TheList}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<Grid/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
Run Code Online (Sandbox Code Playgroud)
在ItemsControl's中ItemContainerStyle,您可能希望将Grid.Row和Grid.Column附加属性绑定到项的某些属性:
<ItemsControl.ItemContainerStyle>
<Style TargetType="{x:Type FrameworkElement}">
<Setter Property="Grid.Row" Value="{Binding RowIndex}"/>
<Setter Property="Grid.Column" Value="{Binding ColumnIndex}"/>
</Style>
</ItemsControl.ItemContainerStyle>
Run Code Online (Sandbox Code Playgroud)