簡體   English   中英

動態更新Silverlight子元素的高度和寬度

[英]Updating the height and width of a Silverlight child element dynamically

我在Silverlight應用程序中遇到了這個特殊的問題。 我有一個具有一些Path元素的Canvas。 我需要在這些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;

似乎即使我強制轉換也無法訪問這些屬性。

誰能幫我嗎?

謝謝!

您正在投射HeightWidth屬性,而不是Path對象。 嘗試這個:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM