1

グリッド内のコンポーネントの配置に問題があります。

atmの出力は次のとおりです。

ここに画像の説明を入力してください

私がやりたいのは、次のようにコンポーネントを並べて配置することです。

ここに画像の説明を入力してください

これが私の現在のコードです:

<Grid x:Name="Components" Margin="8,8,0,8">
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto" />
        <RowDefinition Height="Auto" />
        <RowDefinition Height="*" />
    </Grid.RowDefinitions>                  
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="Auto" />
        <ColumnDefinition Width="Auto" />
        <ColumnDefinition Width="*" />
    </Grid.ColumnDefinitions>

    <Label Grid.Row="1" Grid.Column="0" Content="{Binding .[Language.timeOptions1], Mode=OneWay, Source={StaticResource localisation}}" HorizontalAlignment="Left" VerticalAlignment="Top" FontSize="11" Foreground="#FF585858" FontFamily="Myriad Pro" Height="23.2"/>
    <TextBox Grid.Row="1" Grid.Column="1" MaxLength="2" x:Name="textTimeHour" TextWrapping="NoWrap" VerticalAlignment="Top" HorizontalAlignment="Left" FontFamily="Myriad Pro" Style="{DynamicResource style1Text}" Height="25.2"/>
    <Label Grid.Row="1" Grid.Column="1" Content=":" HorizontalAlignment="Left" FontSize="11" Foreground="#FF585858" FontFamily="Myriad Pro" VerticalAlignment="Top"/>
    <TextBox Grid.Row="1" Grid.Column="2" MaxLength="1" x:Name="textTimeMin" TextWrapping="NoWrap" VerticalAlignment="Top" FontFamily="Myriad Pro" Style="{DynamicResource style1Text}" Height="25.2" HorizontalAlignment="Left" Width="Auto"/>
    <Button Width="80" Grid.Row="1" Grid.Column="2" x:Name="btnNow" Content="{Binding .[Language.now], Mode=OneWay, Source={StaticResource localisation}}" VerticalAlignment="Top" Style="{DynamicResource style1Btn}" Height="25.2" FontSize="9.333" Click="btnNow_Click"/>
    <TextBlock Grid.Row="2" Grid.Column="0" x:Name="blockIgnoreDate" Text="{Binding .[Language.timeOptions2], Mode=OneWay, Source={StaticResource localisation}}" HorizontalAlignment="Left" FontSize="11" Foreground="#FF585858" FontFamily="Myriad Pro" Height="23.202"/>
    <Custom:DatePicker  Grid.Row="2" Grid.Column="1" x:Name="pickerDate" d:LayoutOverrides="Width" FontFamily="Myriad Pro" IsTodayHighlighted="False" Foreground="#FF585858" Height="24" />
    <CheckBox Grid.Row="2" Grid.Column="2" x:Name="checkIgnoreDate" Content="{Binding .[Language.ignoreDate], Mode=OneWay, Source={StaticResource localisation}}" Foreground="#FF585858" Background="{x:Null}" Checked="checkIgnoreDate_Checked" Unchecked="checkIgnoreDate_Unchecked" Height="15.96"/>
    <Button Grid.Row="3" Grid.Column="0" x:Name="btnAddTask" Content="{Binding .[Language.addTask], Mode=OneWay, Source={StaticResource localisation}}" HorizontalAlignment="Left" VerticalAlignment="Bottom" Style="{DynamicResource style1Btn}" Click="btnAddTask_Click" Height="24.65"/>
</Grid>

誰かが私を正しい方向に向けることができますか?

4

2 に答える 2

1

時間コントロールを 内に置き、コントロールのStackPanelを に変更しVerticalAlignmentますCenter

<Label Grid.Row="1" Grid.Column="0" Content="{Binding .[Language.timeOptions1],
       Mode=OneWay, Source={StaticResource localisation}}" HorizontalAlignment="Left"
       VerticalAlignment="Center" FontSize="11" Foreground="#FF585858"
       FontFamily="Myriad Pro" Height="23.2"/>
<StackPanel Orientation="Horizontal" Grid.Row="1" Grid.Column="1">
    <TextBox MaxLength="2" x:Name="textTimeHour" TextWrapping="NoWrap"
             VerticalAlignment="Center" HorizontalAlignment="Left"
             FontFamily="Myriad Pro" Style="{DynamicResource style1Text}"
             Height="25.2"/>
    <Label Content=":" HorizontalAlignment="Left" FontSize="11" Foreground="#FF585858"
           FontFamily="Myriad Pro" VerticalAlignment="Center"/>
    <TextBox MaxLength="1" x:Name="textTimeMin" TextWrapping="NoWrap"
             VerticalAlignment="Top" FontFamily="Myriad Pro"
             Style="{DynamicResource style1Text}" Height="25.2"
             HorizontalAlignment="Left" Width="Auto"/>
    <Button Width="80" x:Name="btnNow" Content="{Binding .[Language.now], Mode=OneWay,
           Source={StaticResource localisation}}" VerticalAlignment="Center"
           Style="{DynamicResource style1Btn}" Height="25.2" FontSize="9.333"
           Click="btnNow_Click"/>
</StackPanel>

にマージンを追加したり、同様にCheckBox設定したりすることもできます。HorizontalAlignmentCenter

于 2012-06-09T11:21:59.273 に答える
0

textTimeMin テキスト ボックスと btnNow の Grid.Column を 1 に変更し、textTimeHour、textTimeMin、: ラベル、および btnNow に Grid.ColumnSpan="2" を設定します。

<Label Grid.Row="1" Grid.Column="0" Content="{Binding .[Language.timeOptions1], Mode=OneWay, Source={StaticResource localisation}}" HorizontalAlignment="Left" VerticalAlignment="Top" FontSize="11" Foreground="#FF585858" FontFamily="Myriad Pro" Height="23.2"/>
<TextBox Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="2" MaxLength="2" x:Name="textTimeHour" TextWrapping="NoWrap" VerticalAlignment="Top" HorizontalAlignment="Left" FontFamily="Myriad Pro" Style="{DynamicResource style1Text}" Height="25.2"/>
<Label Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="2" Content=":" HorizontalAlignment="Left" FontSize="11" Foreground="#FF585858" FontFamily="Myriad Pro" VerticalAlignment="Top"/>
<TextBox Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="2" MaxLength="1" x:Name="textTimeMin" TextWrapping="NoWrap" VerticalAlignment="Top" FontFamily="Myriad Pro" Style="{DynamicResource style1Text}" Height="25.2" HorizontalAlignment="Left" Width="Auto"/>
<Button Width="80" Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="2" x:Name="btnNow" Content="{Binding .[Language.now], Mode=OneWay, Source={StaticResource localisation}}" VerticalAlignment="Top" Style="{DynamicResource style1Btn}" Height="25.2" FontSize="9.333" Click="btnNow_Click"/>

今はテストできませんが、目的を達成するには Grid.Column と Grid.ColumnSpan を正しく使用する必要があります。

于 2012-06-09T11:09:19.830 に答える