I have a WPF application and Canvas in there. In Canvas I have a Rectangle. How can I change his properties, like Height or Width while program is already processing? Something like:
int index = 0;
var childByIndex = canvas.Children[index];
childByIndex.SetValue(Height, 15);
You will have to tell which dp of which type you want to set like below:
The easiest way would be to give your rectangle a name in XAML and then use it in your code:
If for some reason you can't give your rectangle a name in XAML, you can cast your found object to
Rectangle
before doing the operation:If you're looking to change an attached property, like the location in the canvas, you can do it like this: