网格列宽 - 混合*(星号)、自动并填充左侧空间 [英] Grid Column Width - mix *(star), Auto and fill left space

查看:28
本文介绍了网格列宽 - 混合*(星号)、自动并填充左侧空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在列定义之后有一个网格宽度:

I have a Grid width following Column Definitions:

<Grid.ColumnDefinitions>
        <ColumnDefinition MinWidth="320" MaxWidth="450" Width=".32*"/>
        <ColumnDefinition MinWidth="200" Width="Auto"/>
        <ColumnDefinition MinWidth="200" Width="Auto"/>
        <ColumnDefinition Width="Auto"/> <- (4) should fill all available space
        <ColumnDefinition MinWidth="250" MaxWidth="300" Width=".20*"/>
</Grid.ColumnDefinitions>

问题是在第 (4) 列上将宽度设置为 Auto 会将其宽度归零,最后一列紧邻第三列.我想让最后一列与应用的右边缘对齐,前三列在左侧.

The problem is that setting width to Auto on column (4) zeros it's width and last column is next to third one. I'd like to have last column aligned to right edge of app and first three to the left.

我也无法将 (4) 宽度设置为星号 (*) - 显然它相对于第一列和最后一列延伸.

I also can't set (4) width to star(*) - obviously it stretches relatively to first and last column.

我一直在尝试使用水平对齐方式,但结果是 - 内容没有填满列宽.我可以将内容宽度绑定到列宽或类似的东西,但我很好奇是否有一些简单的方法可以实现 (4) 列填充所有剩余空间.

I've been trying for a while with horizontalalignments but as a result - content is not filling the columns width. I could maybe bind content width to column width or sth like that, but I'm curious whether there is some easy way to achive the (4) column fill all left space.

推荐答案

我想你并没有完全理解代表加权平均的 (*).

I think you didnt quite undestand the (*) which stands for weighted average.

所以你的情况.

<Grid.ColumnDefinitions>
     <ColumnDefinition MinWidth="320" MaxWidth="450" Width="3*"/>
     <ColumnDefinition MinWidth="200" Width="Auto"/>
     <ColumnDefinition MinWidth="200" Width="Auto"/>
     <ColumnDefinition Width="5*"/>
     <ColumnDefinition MinWidth="250" MaxWidth="300" Width="2*"/>
 </Grid.ColumnDefinitions> 

如果您希望第 (4) 列变小,请减少 * 权重并在您喜欢的地方增加.

if you wish to make the column (4) small reduce the * weightage and increase where you like.

希望对你有帮助...

这篇关于网格列宽 - 混合*(星号)、自动并填充左侧空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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