在Grid WPF中对齐标签

时间:2012-06-08 18:11:11

标签: wpf xaml grid

我有一个对齐问题,我试图从头到尾定位标签,但它们是从中间开始的。有人可以说明我需要做些什么来改变它并让它按照我想要的方式调整。

enter image description here

        <Grid Height="23.3" Margin="169,0,8,8.199" VerticalAlignment="Bottom" Width="Auto">
<Grid.ColumnDefinitions>
    <ColumnDefinition Width="*" />
    <ColumnDefinition Width="*" />
    <ColumnDefinition Width="*" />
    <ColumnDefinition Width="*" />
    <ColumnDefinition Width="*" />
    <ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
            <Rectangle Grid.ColumnSpan="6" Fill="#FFDDDDDD" Stroke="#FFD7D7D7" RadiusX="2" RadiusY="2"/>


            <Label Grid.Column="1" Grid.Row="1" x:Name="lblAbout" Content="{Binding Source={StaticResource localisation}, Mode=OneWay, Path=.[Language.about]}" HorizontalAlignment="Left" Foreground="#FF585858" FontSize="10" Cursor="Hand" d:LayoutOverrides="Height" MouseLeftButtonUp="lblAbout_MouseLeftButtonUp"/>
            <Label Grid.Column="2" Grid.Row="1" Content="{Binding Source={StaticResource localisation}, Mode=OneWay, Path=.[Language.settings]}" HorizontalAlignment="Left" Foreground="#FF585858" FontSize="10" Cursor="Hand" d:LayoutOverrides="Height"/>
            <Label Grid.Column="3" Grid.Row="1" Content="{Binding Source={StaticResource localisation}, Mode=OneWay, Path=.[Language.feedback]}" Foreground="#FF585858" FontSize="10" Cursor="Hand" HorizontalAlignment="Left" Width="Auto" d:LayoutOverrides="Height"/>
            <Label Grid.Column="4" Grid.Row="1" Content="{Binding Source={StaticResource localisation}, Mode=OneWay, Path=.[Language.help]}" Foreground="#FF585858" FontSize="10" Cursor="Hand" HorizontalAlignment="Left" Width="Auto" d:LayoutOverrides="Height"/>
            <Label Grid.Column="1" Grid.Row="1" Content="{Binding Source={StaticResource localisation}, Mode=OneWay, Path=.[Language.checkingUpdates]}" Foreground="#FF585858" FontSize="10" Cursor="Hand" d:LayoutOverrides="Height" Visibility="Collapsed"/>
        </Grid>

1 个答案:

答案 0 :(得分:3)

目前,由于您的所有色谱柱都使用星形尺寸,因此它们的尺寸均匀且在整个宽度范围内拉伸。

我相信你想要:

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

这将使它们从左向右堆叠,并在末尾“填充”。