In XAML, when you want your controls to resize based on the Container, you set the Height or Width property to "Auto". Yesterday, I wanted to set this from code and I could not find a way to do this. Height/Width is a Double and setting 0 actually makes the control invisible (or almost so).
A little bit of searching pointed me to MSDN. The answer is documented in MSDN, but not very easy to find unless you are the type who reads every line that appears in the related pages. I usually just read the main parts and skip to the examples. :)
"In addition to acceptable Double values, this property can also be Double..::.NaN. This is how you specify auto sizing behavior in code. In XAML you set the value to the string "Auto" (case insensitive) to enable the auto sizing behavior. Auto sizing behavior implies that the element will fill the height available to it."
http://msdn.microsoft.com/en-us/library/system.windows.frameworkelement.height.aspx


Comments