我有这个 XAML,在运行时我想知道如何更改作为 WrapGrid 对象属性的 MaximumRowsOrColumns 属性的值:
<ScrollViewer x:Name="LayoutRoot" IsTabStop="True">
<ItemsControl Name="m_pageContainer" ScrollViewer.HorizontalScrollBarVisibility="Hidden" ScrollViewer.VerticalScrollBarVisibility="Hidden" HorizontalAlignment="Center" VerticalAlignment="Center">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapGrid Orientation="Horizontal" MaximumRowsOrColumns="2"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<Rectangle Margin="10,10,10,10" Height="50" Width="40" Fill="Pink" />
<Rectangle Margin="10,10,10,10" Height="50" Width="40" Fill="YellowGreen" />
<Rectangle Margin="10,10,10,10" Height="50" Width="40" Fill="Blue" />
<Rectangle Margin="10,10,10,10" Height="50" Width="40" Fill="Red" />
<Rectangle Margin="10,10,10,10" Height="50" Width="40" Fill="Yellow" />
<Rectangle Margin="10,10,10,10" Height="50" Width="40" Fill="Green" />
<Rectangle Margin="10,10,10,10" Height="50" Width="40" Fill="Gray" />
<Rectangle Margin="10,10,10,10" Height="50" Width="40" Fill="LightBlue" />
</ItemsControl>
</ScrollViewer>
我一直在徒劳地寻找在 C# 或 C++/CX 中执行此操作的方法。
谢谢
罗杰