码迷,mamicode.com
首页 > 其他好文 > 详细

WPF中Auto与*的差别

时间:2014-09-30 16:54:59      阅读:133      评论:0      收藏:0      [点我收藏+]

标签:des   style   http   color   io   os   使用   ar   sp   

Auto 表示自己主动适应显示内容的宽度, 如自己主动适应文本的宽度,文本有多长,控件就显示多长.

* 则表示按比例来分配宽度.


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

bubuko.com,布布扣

相同,行能够这样定义

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

这些数字能够是小数.
假设数字缺省,则默认是1.
在这个样例中, 列2的宽度是列1的1.5倍.

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

bubuko.com,布布扣

Auto和*能够混合使用. 在这个样例中,后两行的宽度在前两行分配完之后,按比例获取剩余的宽度.

<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" />

bubuko.com,布布扣


WPF中Auto与*的差别

标签:des   style   http   color   io   os   使用   ar   sp   

原文地址:http://www.cnblogs.com/gcczhongduan/p/4001964.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!