我需要在自定義面板中計算每個UIElement
的Width
。如果遍歷Children
:如何設置UIElement的DesiredSize.Width?
foreach (UIElement child in Children) { ... }
我不能這樣做,因爲child.DesiredSize.Width = myCalculatedWidth;
和DesiredSize
DesiredSize.Width
是隻讀的。
的文檔說是Measure()
更新UIElement
的DesiredSize
,所以我嘗試:
Size size = new Size(myCalculatedWidth, Double.PositiveInfinity);
child.Measure(size);
但child.DesiredSize.Width
不變。我如何設置DesiredSize.Width
?
'UIElement'沒有'Width'屬性。 – d7samurai