Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# WPF-如何用正方形填充窗口_C#_Wpf - Fatal编程技术网

C# WPF-如何用正方形填充窗口

C# WPF-如何用正方形填充窗口,c#,wpf,C#,Wpf,嘿,伙计们,我有一个wpf应用程序,我想制作一个100x100的正方形网格,并能够在我的代码中将其视为一个普通的集合(列表、数组等) 在WPF中,如果不写入10000次,我怎么能做到这一点呢?您可以尝试使用WrapPanel与ItemsControl组合来实现这一点: <ItemsControl x:Name="RectanglesItemsControl"> <ItemsControl.ItemsPanel> <ItemsPanelTempl

嘿,伙计们,我有一个wpf应用程序,我想制作一个100x100的正方形网格,并能够在我的代码中将其视为一个普通的集合(列表、数组等)


在WPF中,如果不写入
10000次,我怎么能做到这一点呢?

您可以尝试使用
WrapPanel
ItemsControl
组合来实现这一点:

<ItemsControl x:Name="RectanglesItemsControl">
    <ItemsControl.ItemsPanel>
       <ItemsPanelTemplate>
           <WrapPanel IsItemsHost="True"/>
       </ItemsPanelTemplate>
    </ItemsControl.ItemsPanel>
    <ItemsControl.ItemTemplate>
         <DataTemplate DataType="myNamespace:MyType">
             <Rectangle Width="{Binding Width}" Height="{Binding Height}"/>
         </DataTemplate>
    </ItemsControl.ItemTemplate>
</ItemsControl>

编辑:您可以将
WrapPanel
替换为您想要的任何内容,您也可以使用
来拥有100行和100列。

您可以尝试将
WrapPanel
项控件结合使用来完成以下操作:

<ItemsControl x:Name="RectanglesItemsControl">
    <ItemsControl.ItemsPanel>
       <ItemsPanelTemplate>
           <WrapPanel IsItemsHost="True"/>
       </ItemsPanelTemplate>
    </ItemsControl.ItemsPanel>
    <ItemsControl.ItemTemplate>
         <DataTemplate DataType="myNamespace:MyType">
             <Rectangle Width="{Binding Width}" Height="{Binding Height}"/>
         </DataTemplate>
    </ItemsControl.ItemTemplate>
</ItemsControl>

编辑:你可以用你想要的任何东西替换
WrapPanel
,你也可以使用
来拥有100行和100列。

要制作
WrapGrid
100x100,你还需要设置一些属性。是的,你也可以使用
UniformGrid
来实现这一点。我将对其进行编辑以使
WrapGrid
100x100,您还需要设置一些属性。是的,您也可以使用
UniformGrid
来实现。我会编辑的