silverlight: How to set attached properties Programmatically


Answers

Actually to clear a value you should use this:

textBlock.ClearValue(Grid.RowProperty);
Question

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?




LayoutGrid SetRow and SetColumn not working as intended

Although the comment in your second section of code says:

//create a stack object

you don't actually create a new stack object so it is simply overwriting the single instance of buttonData on each iteration. The values for row and column that you see at the end are the last iteration's values.

The net effect is that stacks is a collection of all the same instance of an object instead of a collection of separate instances.





Tags