silverlight: How to set attached properties Programmatically

女生的网名这么多〃 提交于 2019-12-03 01:24:01

To set the value:

textBlock.SetValue(Grid.RowProperty, 3);

To reset the value:

textBlock.SetValue(Grid.RowProperty, null);

Actually to clear a value you should use this:

textBlock.ClearValue(Grid.RowProperty);

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); 
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!