怎么说XAML<按钮高度="自动" />在后面的代码? [英] How to say XAML <Button Height="Auto"/> in code behind?
本文介绍了怎么说XAML<按钮高度="自动" />在后面的代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您如何设置 HEIGHT =*
和 HEIGHT =自动
在后面的代码?
How can you set Height="*"
and Height="Auto"
in code behind?
推荐答案
有关设置 HEIGHT =自动
上的大多数控件,你想与 double.NaN
分配值
For setting Height = "Auto"
on most controls, you want to assign the value with double.NaN
.
例如:
element.Height = double.NaN;
设置宽度/高度=*
(是一个稍微不同的问题,因为它只适用于有选择的几个元素( ColumnDefinition
和 RowDefinition
为例)。该类型宽度
/ 身高
值的 GridLength
,而不是双击
Setting Width/Height = "*"
( is a slightly different matter, since it only applies to a select few elements (ColumnDefinition
and RowDefinition
for example). The type of the Width
/Height
value is GridLength
, rather than double
.
示例(更多的是在给定的这个MSDN页面:
Example (more are given on this MSDN page:
column1.Width = new GridLength(1, GridUnitType.Auto); // Auto
column2.Width = new GridLength(1, GridUnitType.Star); // *
这篇关于怎么说XAML<按钮高度="自动" />在后面的代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文