动态地更新Silverlight子元素的高度和宽度

本文关键字:高度 元素 更新 Silverlight 动态 | 更新日期: 2023-09-27 18:17:26

我在我的silverlight应用程序中面临这个特殊的问题。我有一个有几个路径元素的画布。我需要在其中一个Path元素上加载另一个UIElement。我有它的代码,它都设置好了。

唯一的问题是我无法更新这些Path元素的Height和Width

我想知道我是否可以这样做,

    (Path) this.canvas_name.Children[index].Height = height_of_a_UIElement;
    (Path) this.canvas_name.Children[index].Width  = width_of_a_UIElement;

似乎即使我强制转换,我也不能访问这些属性。

有人能帮我吗?

谢谢!

动态地更新Silverlight子元素的高度和宽度

您正在转换HeightWidth属性,而不是Path对象。试试这个:

((Path) this.canvas_name.Children[index]).Height = height_of_a_UIElement;
((Path) this.canvas_name.Children[index]).Width  = width_of_a_UIElement;