views:

219

answers:

1

I need to calculate the width of each UIElement in a custom panel. If looping over Children: foreach (UIElement child in Children) { ... }

I can't do child.DesiredSize.Width = myCalculatedWidth;

Since DesiredSize and DesiredSize.Width are read only.

The docs say that that Measure() updates the DesiredSize of the UIElement, so I tried: Size size = new Size(myCalculatedWidth, Double.PositiveInfinity); child.Measure(size);

But child.DesiredSize.Width is unchanged. How do I set the DesiredSize.Width?

+1  A: 

Just try with child.Width = myCalculatedWidth

Fabrice