HOW TO CHANGE A VALUE OF UIELEMENT?

Ankita Pandey

Total Post:183

Points:1285
Posted by  Ankita Pandey
WPF 
WPF
 911  View(s)
Ratings:
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);

  1. Sumit Kesarwani

    Post:378

    Points:2694
    Re: How to change a value of UIElement?

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

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!