Arranging collection items in a grid

前端 未结 1 1388
离开以前
离开以前 2020-12-17 02:33

I would like to arrange items of a collection in a grid with a specific number of columns and rows (say 4x6). Each item exposes the dependency properties (integer) X and Y a

相关标签:
1条回答
  • 2020-12-17 02:38
    <ItemsControl ItemsSource="{Binding YourItems}">
        <ItemsControl.ItemsPanel>
            <ItemsPanelTemplate>
                <Grid/>
            </ItemsPanelTemplate>
        </ItemsControl.ItemsPanel>
        <ItemsControl.ItemContainerStyle>
            <Style>
                <Setter Property="Grid.Column" Value="{Binding X}"/>
                <Setter Property="Grid.Row" Value="{Binding Y}"/>
            </Style>
        </ItemsControl.ItemContainerStyle>
    </ItemsControl>
    
    0 讨论(0)
提交回复
热议问题