如何在后面的c#代码中设置该UniformGrid的Rows和Columns?
<ListBox x:Name="galerielb" Margin="10,0,0,10"
ItemContainerStyle="{StaticResource SimpleListBoxItem}">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<UniformGrid Rows="10" Columns="6"/>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
</ListBox>发布于 2019-07-01 19:59:45
因为它只是一个模板,所以您可以创建一个新的模板并直接设置ItemsPanel属性:
FrameworkElementFactory ug = new FrameworkElementFactory(UniformGrid);
ug.SetValue(UniformGrid.RowsProperty, 10);
ug.SetValue(UniformGrid.ColumnsProperty, 6);
galerielb.ItemsPanel = new ItemsPanelTemplate(ug);https://stackoverflow.com/questions/56835202
复制相似问题