3
代碼更改屬性的值,我有這樣的XAML和運行時,我想知道我怎麼可以改變MaximumRowsOrColumns的屬性值也就是WrapGrid對象的屬性:在運行時
<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中執行此操作的方法。
感謝
羅傑
你有沒有試過將它的值綁定到你的ViewModel或你的等價物上? – mydogisbox