Home > DeveloperSection > Forums > How to change a value of UIElement?
Ankita Pandey
Ankita Pandey

Total Post:183

Posted on    September-23-2013 4:57 AM


 1 Reply(s)
 685  View(s)
Rate this:

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);

Sumit Kesarwani

Total Post:378

Posted on    September-23-2013 6:59 AM

Hi Ankita,

You will have to tell which dp of which type you want to set like below:

((Rectangle)canvas.Children[index]).SetValue(Rectangle.HeightProperty, 15.0);

Don't want to miss updates? Please click the below button!

Follow MindStick