WPF明星做什么(宽度=“100 *”) [英] What does the WPF star do (Width="100*")

查看:216
本文介绍了WPF明星做什么(宽度=“100 *”)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在WPF中,星号的大小意味着什么?

解决方案

在WPF Grid中,宽度=*高度=*表示比例大小。

例如:给30%到第1列和70%到第2列 -

 < ColumnDefinition Width =3 */> 
< ColumnDefinition Width =7 */>


对于行也是如此 -

 < RowDefinition Height =3 */> 
< RowDefinition Height =7 */>

数字不一定是整数。

如果RowDefinition的宽度(ColumnDefinition的高度)被忽略,隐含1 *。
在这个例子中,第1列比第2列宽1.5倍 -

 < ColumnDefinition Width =1.5 */> 
< ColumnDefinition />



您可以将自动拟合宽度和固定宽度与*(比例)在这种情况下,在自动拟合宽度和固定宽度计算完毕后,*列被分配给剩余的列 -

 < Grid .ColumnDefinitions> 
< ColumnDefinition Width =Auto/> <! - 自动适应内容,'嗨' - >
< ColumnDefinition Width =50.5/> <! - 固定宽度:50.5个装置单位) - >
< ColumnDefinition Width =69 */> < - 取69%余数 - >
< ColumnDefinition Width =31 */> <! - 取31%余数 - >
< /Grid.ColumnDefinitions>
< TextBlock Text =HiGrid.Column =0/>


What does exactly the star in size terms in WPF mean?

解决方案

In a WPF Grid, Width="*" or Height="*" means proportional sizing.
For example: to give 30% to column 1 and 70% to column 2 -

<ColumnDefinition Width="3*" />
<ColumnDefinition Width="7*" />

And likewise for rows -

<RowDefinition Height="3*" />
<RowDefinition Height="7*" />

The numbers do not have to be integers.
If the Width for RowDefinition (Height for ColumnDefinition) is omitted, 1* is implied.
In this example, column 1 is 1.5 times wider than column 2 -

<ColumnDefinition Width="1.5*" />
<ColumnDefinition />

You can mix auto-fit and fixed widths with * (proportional) widths; in that case the * columns are apportioned to the remainder after the auto-fit and fixed widths have been calculated -

<Grid.ColumnDefinitions>
    <ColumnDefinition Width="Auto" />  <!-- Auto-fit to content, 'Hi' -->
    <ColumnDefinition Width="50.5" />  <!-- Fixed width: 50.5 device units) -->
    <ColumnDefinition Width="69*" />   <!-- Take 69% of remainder -->
    <ColumnDefinition Width="31*"/>    <!-- Take 31% of remainder -->
</Grid.ColumnDefinitions>
<TextBlock Text="Hi" Grid.Column="0" />

这篇关于WPF明星做什么(宽度=“100 *”)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆