C# 如何在代码隐藏中调用控件

C# 如何在代码隐藏中调用控件,c#,wpf,datagrid,C#,Wpf,Datagrid,如何在代码隐藏中对齐控件 Grid.SetRow(dt,1); // set position LayoutRoot.Children.Add(dt); // add control into the Grid XAML: 对于第二行,设置Grid.row属性,如下所示: DataGrid dt = new DataGrid(); Grid.SetRow(dt ,1); LayoutRoot.Children.Add(dt); 对于第二行,设置Grid.row属性,如下所

如何在代码隐藏中对齐控件

Grid.SetRow(dt,1); // set position
LayoutRoot.Children.Add(dt); // add control into the Grid
XAML:


对于第二行,设置Grid.row属性,如下所示:

   DataGrid dt = new DataGrid();
   Grid.SetRow(dt ,1);

   LayoutRoot.Children.Add(dt);

对于第二行,设置Grid.row属性,如下所示:

   DataGrid dt = new DataGrid();
   Grid.SetRow(dt ,1);

   LayoutRoot.Children.Add(dt);
可以使用Grid.SetRow()和Grid.SetColumn()函数从代码隐藏中设置位置

Grid.SetRow(dt,1); // set position
LayoutRoot.Children.Add(dt); // add control into the Grid
可以使用Grid.SetRow()和Grid.SetColumn()函数从代码隐藏中设置位置

Grid.SetRow(dt,1); // set position
LayoutRoot.Children.Add(dt); // add control into the Grid

只需添加它并将
Grid.Row=“1”
设置为已有2行。必须添加它并将
Grid.Row=“1”
设置为已有2行