2011-12-09 82 views
1

我在Silverlight应用程序中遇到了这个特殊问题。我有一个有几个Path元素的Canvas。我需要在这些Path元素之一上加载另一个UIElement。我有它的代码,它全部设置。动态更新Silverlight子元素的高度和宽度

我面临的唯一问题是我无法更新这些路径元素的高度和宽度。

我在想,如果我可以做这样的事情,

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

好像即使我投它,我无法访问这些属性。

任何人都可以帮我吗?

谢谢!

+0

检查Visual Studio中的数据类型,按Ctrl + Shift +空格当光标广场brackets.It之间将帮助你正确地投 –

回答

0

您铸造HeightWidth性质,而不是Path对象。试试这个:

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

我无法相信我就是这么做的!非常感谢你RobSiklos! – Hsarp