简体   繁体   English

在WPF中设置网格布局的宽度

[英]Setting the width of a grid layout in WPF

Im new to WPF and im annoyed I cant find this answer anywhere on the net. 我是WPF的新手,我很生气,在网上的任何地方都找不到这个答案。

I want to set the a gridlayout to have 3 columns. 我想将gridlayout设置为3列。 The first to be a quarter of the available width, the second to be half the available width and the third to be a quarter of the available width. 第一个是可用宽度的四分之一,第二个是可用宽度的一半,第三个是可用宽度的四分之一。

Is this possible and if so could someone provide me the Xaml? 这可能吗,如果可以,有人可以给我Xaml吗?

Kind Regards 亲切的问候

Ash

<Grid>
  <Grid.ColumnDefinitions>
     <ColumnDefinition Width="25*" />
     <ColumnDefinition Width="50*" />
     <ColumnDefinition Width="25*" />
  </Grid.ColumnDefinitions>
</Grid>

The * postfix means a weighted scale, you could also use 1*, 2*, 1* *后缀表示加权比例,您也可以使用1 *,2 *,1 *

<Grid x:Name="LayoutRoot">
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="0.25*"/>
        <ColumnDefinition Width="0.5*"/>
        <ColumnDefinition Width="0.25*"/>
    </Grid.ColumnDefinitions>
</Grid>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM