Use an ItemsControl
with the ItemsPanel
set to a Grid :
<ItemsControl ItemsSource="{Binding TheList}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<Grid/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
In the ItemsControl
's ItemContainerStyle
, you might want to bind the Grid.Row
and Grid.Column
attached properties to some property of the items :
<ItemsControl.ItemContainerStyle>
<Style TargetType="{x:Type FrameworkElement}">
<Setter Property="Grid.Row" Value="{Binding RowIndex}"/>
<Setter Property="Grid.Column" Value="{Binding ColumnIndex}"/>
</Style>
</ItemsControl.ItemContainerStyle>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…