Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/280.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#windows 8沉浸式应用程序中的移动按钮_C#_Windows 8_Windows Store Apps - Fatal编程技术网

C#windows 8沉浸式应用程序中的移动按钮

C#windows 8沉浸式应用程序中的移动按钮,c#,windows-8,windows-store-apps,C#,Windows 8,Windows Store Apps,我需要用C#编写一个windows 8沉浸式应用程序(windows应用商店应用程序),它要求我以编程方式将按钮随机插入网格 我的Xaml创建的网格如下所示: <Grid x:Name="grid" Style="{StaticResource LayoutRootStyle}"> <Grid.RowDefinitions> <RowDefinition Height="*"/> <RowDefinition He

我需要用C#编写一个windows 8沉浸式应用程序(windows应用商店应用程序),它要求我以编程方式将按钮随机插入网格

我的Xaml创建的网格如下所示:

<Grid x:Name="grid" Style="{StaticResource LayoutRootStyle}">
    <Grid.RowDefinitions>
        <RowDefinition Height="*"/>
        <RowDefinition Height="*"/>
        <RowDefinition Height="*"/>            
    </Grid.RowDefinitions>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="*"/>
        <ColumnDefinition Width="*"/>            
        <ColumnDefinition Width="*"/>
    </Grid.ColumnDefinitions>
</Grid>
然后把它插入网格,但我还没弄明白怎么做。(我想在网格中添加任意数量的按钮,远远小于单元格的数量)

我已经浏览了网格定义,它有一个RowDefinitions和CollumnDefinitions,但这两个定义似乎都不能向单元格中添加内容


有人知道如何做到这一点吗?

您必须将
按钮添加到
网格的子集合中。然后,您可以使用一些静态方法设置按钮的行、列:

// instance method on grid (lower case g)
grid.Children.Add(button1);
// static methods on Grid (upper case G)
Grid.SetRow(button1, 0);
Grid.SetColumn(button1, 0);

这是windows应用商店应用程序还是windows桌面应用程序?我说的是windows应用商店应用程序。谢谢,我已经适当地编辑了这个问题。
// instance method on grid (lower case g)
grid.Children.Add(button1);
// static methods on Grid (upper case G)
Grid.SetRow(button1, 0);
Grid.SetColumn(button1, 0);