如何使用 UWP XAML 在网格中顺时针显示 ItemsControl?
How do I display an ItemsControl clockwise in a Grid using UWP XAML?
我想在矩形网格中顺时针显示列表项;该列表具有恒定大小。我正在尝试下面的内容,但所有项目的文本似乎都在网格的第一行和第一列中重叠。我做错了什么?
<ItemsControl
ItemsSource="{Binding Squares}"
DisplayMemberPath="Value"
>
<ItemsControl.ItemContainerStyle>
<Style TargetType="ContentPresenter">
<Setter Property="Grid.Row" Value="{Binding Row}"/>
<Setter Property="Grid.Column" Value="{Binding Column}"/>
</Style>
</ItemsControl.ItemContainerStyle>
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
</Grid>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
Setter 不支持 UWP 中的绑定(请参阅文档 here)。
但是发布了一个解决方法 。
我想在矩形网格中顺时针显示列表项;该列表具有恒定大小。我正在尝试下面的内容,但所有项目的文本似乎都在网格的第一行和第一列中重叠。我做错了什么?
<ItemsControl
ItemsSource="{Binding Squares}"
DisplayMemberPath="Value"
>
<ItemsControl.ItemContainerStyle>
<Style TargetType="ContentPresenter">
<Setter Property="Grid.Row" Value="{Binding Row}"/>
<Setter Property="Grid.Column" Value="{Binding Column}"/>
</Style>
</ItemsControl.ItemContainerStyle>
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
</Grid>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
Setter 不支持 UWP 中的绑定(请参阅文档 here)。
但是发布了一个解决方法