Suppose I have a grid with some row definitions, and a child control in that grid. How would I go about setting the Grid.Row property of the child control programatically?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
To set the value:
textBlock.SetValue(Grid.RowProperty, 3);
To reset the value:
textBlock.SetValue(Grid.RowProperty, null);
回答2:
Actually to clear a value you should use this:
textBlock.ClearValue(Grid.RowProperty);
回答3:
I'm not 100% sure this is in SilverLight, but in WPF you call a static method (called SetX, where X is the property) on the type the attached property is defined on and pass it in which control to set the value on, and the value:
Grid.SetRow(MyControl, myRowNumber);