0
votes

I have a control and its position and size is dependent on a property value that can change at runtime. Either it's width or height can be set by the horizontal/vertical alignment to "stretch".

I have a scenario where I am first in one mode where I want it to stretch vertically. I set the width manually in code behind, and the VerticalAlignment is set to Stretch. Then the property get's updated, and I want to instead set the height explicitly and set the HorizontalAlignment to Stretch.

I even added calls to

this.InvalidateMeasure();
this.InvalidateArrange();

after the property changes, but it does not seem to work. After for example the Height has been set to a number, it does not get overridden like I want it to.

MSDN page does state:

When Height and Width properties are explicitly set on an element, these measurements take higher precedent during layout and will cancel the typical effects of setting HorizontalAlignment to Stretch.

So how do I "unset" the width/height properties of the control?

1

1 Answers

0
votes

You can set height to Double.NaN and Width to Double.NaN