【问题标题】:Updating the height and width of a Silverlight child element dynamically动态更新 Silverlight 子元素的高度和宽度
【发布时间】:2012-01-16 23:08:22
【问题描述】:

我在 silverlight 应用程序中遇到了这个特殊问题。我有一个包含一些路径元素的画布。我需要在这些 Path 元素之一之上加载另一个 UIElement。我有它的代码,一切都准备好了。

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

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

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

似乎即使我投射它,我也无法访问这些属性。

谁能帮帮我?

谢谢!

【问题讨论】:

  • 当光标在方括号之间时,按ctrl+shift+space检查Visual Studio中的数据类型。它将帮助您正确投射

标签: c# silverlight-4.0 height width


【解决方案1】:

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

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

【讨论】:

  • 我不敢相信我正在这样做!非常感谢 RobSiklos!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多