【发布时间】:2009-09-30 12:53:00
【问题描述】:
如何在后面的代码中设置Height="*" 和Height="Auto"?
【问题讨论】:
如何在后面的代码中设置Height="*" 和Height="Auto"?
【问题讨论】:
要在大多数控件上设置Height = "Auto",您需要使用double.NaN 分配值。
例子:
element.Height = double.NaN;
设置Width/Height = "*" ( 稍有不同,因为它只适用于少数几个元素(例如ColumnDefinition 和RowDefinition)。Width/Height 值的类型是@987654321 @,而不是double。
示例(更多内容请参见this MSDN page:
column1.Width = new GridLength(1, GridUnitType.Auto); // Auto
column2.Width = new GridLength(1, GridUnitType.Star); // *
【讨论】: