---
title: "How to change a value of UIElement?"  
description: "How to change a value of UIElement?"  
author: "Anonymous User"  
published: 2013-09-23  
updated: 2013-09-23  
canonical: https://www.mindstick.com/forum/1488/how-to-change-a-value-of-uielement  
category: "wpf"  
tags: ["wpf"]  
reading_time: 1 minute  

---

# How to change a value of UIElement?

I have a [WPF](https://www.mindstick.com/forum/304/wpf) [application](https://www.mindstick.com/articles/12824/calculator-application-in-android) and [Canvas](https://www.mindstick.com/forum/1383/how-can-i-print-a-canvas-in-wpf) in there. In Canvas I have a Rectangle. How can I change his [properties](https://www.mindstick.com/articles/23331/nootropics-7-different-types-and-their-unique-properties), like Height or Width while [program](https://www.mindstick.com/blog/12337/scaling-up-your-mentorship-program) is [already](https://yourviews.mindstick.com/view/88453/the-hidden-ways-ai-is-already-controlling-your-daily-life) [processing](https://www.mindstick.com/blog/254/background-processing-in-android)? Something like:

[int](https://www.mindstick.com/forum/159137/how-to-convert-date-int-to-date-in-sql) [index](https://www.mindstick.com/blog/198/index-in-sql-server) = 0;

[var](https://www.mindstick.com/forum/33920/what-is-different-var-and-dynamic-types-in-c-sharp) childByIndex = canvas.Children[index];

childByIndex.SetValue(Height, 15);

## Replies

### Reply by Sumit Kesarwani

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);


---

Original Source: https://www.mindstick.com/forum/1488/how-to-change-a-value-of-uielement

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
