[UWP] [C#]如何在UWP的C#代码中设置Grid.Row属性? [英] [UWP][C#]How to set Grid.Row property in C# code in UWP?
本文介绍了[UWP] [C#]如何在UWP的C#代码中设置Grid.Row属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的应用程序中,我需要设置控件的一些附加属性(如Grid.Row)
In my App I need to set some Attached properties (like Grid.Row) of controls
它应该是这样的......
It should be like this...
<Grid>
<Button Grid.Row=1/>
</Grid>
但是如何在后台C#代码中实现它?
But how to implement it in the background C# code?
Microsoft Document有这样的例子......
The Microsoft Document has example like this...
Canvas myC = new Canvas();
CheckBox myCheckBox = new CheckBox();
myCheckBox.Content = "Hello";
myC.Children.Add(myCheckBox);
myCheckBox.SetValue(Canvas.TopProperty,75);
...网格似乎不能像这样工作
...Grid seems doesn't work like this
然后我检查了DependencyProperty
then I check the DependencyProperty
public static DependencyProperty Register(String name, Type propertyType, Type ownerType, PropertyMetadata typeMetadata)
但我认为需要在C#代码中设置Grid.Row属性的示例
But I think need an example of setting Grid.Row property in C# code
推荐答案
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Button x:Name="test" Grid.Row="1"></Button>
</Grid>
public MainPage()
{
this.InitializeComponent();
test.SetValue(Grid.RowProperty, 1);
}
你想要这样的东西吗?
You want something like this?
这篇关于[UWP] [C#]如何在UWP的C#代码中设置Grid.Row属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文