1

これらのドックパネルを正しく取得するには?

<DockPanel Grid.Row="1" LastChildFill="True" HorizontalAlignment="Stretch">
    <DockPanel Width="400" LastChildFill="False" HorizontalAlignment="Left">
            <DockPanel>
                <TextBlock Width="400" />
            </DockPanel>
            <DockPanel  Height="35" DockPanel.Dock="Bottom" LastChildFill="False">
                <Button x:Name="btnRefresh" Content="Refersh" />
            </DockPanel>
    </DockPanel>

TextBlock を持つ DockPanel は、下部にドッキングされている DockPanel にまたがっいます。私はそれをぴったり合わせたいと思っています。何か案は?

わかりました。下部にドッキングされたパネルは、xaml 宣言でその上にあるドックパネルより前にある必要があります。LastChildFill="True" は、コードで最後に宣言されたコントロールに適用されます。

<DockPanel Grid.Row="1" LastChildFill="True" HorizontalAlignment="Stretch">
    <DockPanel Width="400" LastChildFill="False" HorizontalAlignment="Left">
        <DockPanel  Height="35" DockPanel.Dock="Bottom" LastChildFill="False">
            <Button x:Name="btnRefresh" Content="Refersh" />
        </DockPanel>
        <DockPanel>
            <TextBlock Width="400" />
        </DockPanel>
    </DockPanel>
4

2 に答える 2

4

必要なヘルプがすべて含まれている MSDNのDockPanel クラスページを参照してください。リンクされたページの XAML の例:

<DockPanel LastChildFill="True">
    <Border Height="25" Background="SkyBlue" BorderBrush="Black" BorderThickness="1" 
        DockPanel.Dock="Top">
        <TextBlock Foreground="Black">Dock = "Top"</TextBlock>
    </Border>
    <Border Height="25" Background="Blue" BorderBrush="Black" BorderThickness="1" 
        DockPanel.Dock="Top">
        <TextBlock Foreground="White">Dock = "Top"</TextBlock>
    </Border>
    <Border Height="25" Background="Yellow" BorderBrush="Black" BorderThickness="1" 
        DockPanel.Dock="Bottom">
        <TextBlock Foreground="Black">Dock = "Bottom"</TextBlock>
    </Border>
    <Border Width="200" Background="PaleGreen" BorderBrush="Black" BorderThickness="1" 
        DockPanel.Dock="Left">
        <TextBlock Foreground="Black">Dock = "Left"</TextBlock>
    </Border>
    <Border Background="White" BorderBrush="Black" BorderThickness="1">
        <TextBlock Foreground="Black">This will fill the remaining space</TextBlock>
    </Border>
</DockPanel>

DockPanel.Dock添付プロパティの使用に注意してください。

ここに画像の説明を入力

于 2013-10-08T15:47:03.677 に答える
2
<DockPanel Grid.Row="1" LastChildFill="True" HorizontalAlignment="Stretch">
   <DockPanel Width="400" LastChildFill="False" HorizontalAlignment="Left">
       <Button x:Name="btnRefresh" Content="Refersh" 
               Height="35" DockPanel.Dock="Bottom" />

       <TextBlock Width="400" />
   </DockPanel>

   <!-- Other UI Elements here? -->

<DockPanel>
于 2013-10-08T15:46:45.950 に答える