如何更改UIElement的值 [英] How to change a value of UIElement

查看:135
本文介绍了如何更改UIElement的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个WPF应用程序和Canvas在那里。在画布中我有一个矩形。如何更改他的属性,如高度或宽度,而程序已经处理?类似:

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


推荐答案

想要设置如下:

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

这篇关于如何更改UIElement的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆