Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/320.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/logging/2.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# 在UWP中以编程方式编辑Grid.rowDefinition_C#_Xaml_Uwp_Uwp Xaml - Fatal编程技术网

C# 在UWP中以编程方式编辑Grid.rowDefinition

C# 在UWP中以编程方式编辑Grid.rowDefinition,c#,xaml,uwp,uwp-xaml,C#,Xaml,Uwp,Uwp Xaml,作为标题,我首先在XAML文件中设置网格的行定义。但是在后面的代码中,我想在某些情况下更改它。那我们有什么办法吗?我们可以这样做吗 grid_socket.SetValue(Grid.ColumnProperty, 0); 您可以访问RowHeight属性访问Grid.RowDefinitions属性。例如,将第一行高度设置为2*: MyGrid.RowDefinitions[0].Height = new GridLength(2, GridUnitType.Star); 或者,您可以命名

作为标题,我首先在XAML文件中设置网格的行定义。但是在后面的代码中,我想在某些情况下更改它。那我们有什么办法吗?我们可以这样做吗

grid_socket.SetValue(Grid.ColumnProperty, 0);

您可以访问
RowHeight
属性访问
Grid.RowDefinitions
属性。例如,将第一行高度设置为
2*

MyGrid.RowDefinitions[0].Height = new GridLength(2, GridUnitType.Star);
或者,您可以命名特定的行定义:

<Grid.RowDefinitions>
    <RowDefinition x:Name="FirstRow" />
    <RowDefinition />
</Grid.RowDefinitions>


然后直接通过
FirstRow
访问代码。

是否要向网格中添加更多行,或者要在特定行中设置任何控件?行定义和列定义用于定义网格中的行/列。假设我已经有两行定义,现在我要编辑第一行定义的属性。可以吗?