0

我有一个布局,我正在尝试制作多语言,但随着过渡而来的是一些障碍。

英语:

在此处输入图像描述

德语:

在此处输入图像描述

如您所见,复选框在网格中飞来飞去,我怎样才能对其进行排序以不与其他控件发生冲突?

谢谢

使用 XAML 编辑:

<Grid x:Name="Block" Margin="23,70,24.002,153">
            <Rectangle Fill="#FFDDDDDD" Stroke="#FFD7D7D7" Height="54" VerticalAlignment="Top" RadiusX="2" RadiusY="2"/>
            <Rectangle Fill="#FFE8E8E8" Margin="0,19,0,0" Stroke="#FFD7D7D7"/>
            <Label Height="22" Content="{Binding Source={StaticResource localisation}, Mode=OneWay, Path=.[Language.settings]}" HorizontalAlignment="Left" VerticalAlignment="Top" FontSize="10" FontFamily="Myriad Pro" Foreground="#FF585858"/>
            <TextBox MaxLength="2" x:Name="textTimeMin" Margin="175.145,34.336,0,0" TextWrapping="NoWrap" VerticalAlignment="Top" FontFamily="Myriad Pro" Style="{DynamicResource style1Text}" Height="25.2" HorizontalAlignment="Left" Width="30"/>
            <TextBox MaxLength="2" x:Name="textTimeHour" Margin="132.868,34.336,0,0" TextWrapping="NoWrap" VerticalAlignment="Top" HorizontalAlignment="Left" Width="30" FontFamily="Myriad Pro" Style="{DynamicResource style1Text}" Height="25.2"/>
            <Label Content=":" HorizontalAlignment="Left" Margin="162.868,35,0,0" FontSize="11" Foreground="#FF585858" FontFamily="Myriad Pro" VerticalAlignment="Top"/>
            <Label Content="{Binding Source={StaticResource localisation}, Mode=OneWay, Path=.[Language.timeOptions1]}" HorizontalAlignment="Left" Margin="6.148,36.332,0,0" VerticalAlignment="Top" FontSize="11" Foreground="#FF585858" FontFamily="Myriad Pro" Height="23.2"/>
            <Label Content="{Binding Source={StaticResource localisation}, Mode=OneWay, Path=.[Language.timeOptions2]}" HorizontalAlignment="Left" Margin="6.148,67.999,0,52.799" FontSize="11" Foreground="#FF585858" FontFamily="Myriad Pro" Height="23.202"/>
            <Custom:DatePicker x:Name="pickerDate" Margin="134,68.149,188,51.851" d:LayoutOverrides=", Height" FontFamily="Myriad Pro" IsTodayHighlighted="False" Foreground="#FF585858"/>
            <Button x:Name="btnAddTask" Content="{Binding Source={StaticResource localisation}, Mode=OneWay, Path=.[Language.addTask]}" HorizontalAlignment="Left" Margin="8,0,0,8" VerticalAlignment="Bottom" Style="{DynamicResource style1Btn}" Click="btnAddTask_Click" Height="24.65"/>
            <CheckBox x:Name="checkIgnoreDate" Content="{Binding Source={StaticResource localisation}, Mode=OneWay, Path=.[Language.ignoreDate]}" HorizontalAlignment="Right" Margin="0,0,105,55.706" VerticalAlignment="Bottom" Foreground="#FF585858" Background="{x:Null}" Checked="checkIgnoreDate_Checked" Unchecked="checkIgnoreDate_Unchecked" Height="15.96"/>
            <Rectangle x:Name="ignoreDateStrike" Fill="#FF444444" Height="1" Margin="6.148,0,199.32,64" VerticalAlignment="Bottom" Visibility="Collapsed"/>
            <Button x:Name="btnNow" Content="{Binding Source={StaticResource localisation}, Mode=OneWay, Path=.[Language.now]}" Margin="206.088,34.27,176.585,0" VerticalAlignment="Top" Style="{DynamicResource style1Btn}" Height="25.2" FontSize="9.333" Click="btnNow_Click"/>
        </Grid>
4

1 回答 1

1

鉴于您的屏幕截图和代码,您可以通过几种不同的方式来解决此问题。

我建议使用具有三列和三行的网格,其中列是自动调整的。这将确保无论您的字段有多长,所有内容都可以很好地排列并很好地适合。

在此处输入图像描述

您的网格代码看起来像这样:

<Grid x:Name="Block">
<Grid.RowDefinitions>
    <RowDefinition Height="Auto" />
    <RowDefinition Height="Auto" />
    <RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
    <ColumnDefinition Width="Auto" />
    <ColumnDefinition Width="Auto" />
    <ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
...   
</Grid>

然后,您只需为网格内的每个项目设置适当的行和列,而不是硬编码它们的边距。

   <Button x:Name="btnAddTask" Grid.Row="1" .... />
于 2012-05-23T21:54:30.563 回答