假设我有一个包含一些行定义的网格,以及该网格中的一个子控件。我将如何以编程方式设置子控件的 Grid.Row 属性?
Jeremy
问问题
7906 次
3 回答
33
要设置值:
textBlock.SetValue(Grid.RowProperty, 3);
要重置值:
textBlock.SetValue(Grid.RowProperty, null);
于 2009-01-08T22:21:24.520 回答
7
实际上要清除一个值,你应该使用这个:
textBlock.ClearValue(Grid.RowProperty);
于 2009-01-09T18:02:38.717 回答
4
我不是 100% 确定这是在 SilverLight 中,但在 WPF 中,您在定义附加属性的类型上调用静态方法(称为 SetX,其中 X 是属性)并将其传递给在哪个控件中设置值, 和值:
Grid.SetRow(MyControl, myRowNumber);
于 2009-01-08T19:35:44.183 回答