开发者

Dock Panel Dock right and left

开发者 https://www.devze.com 2023-03-16 15:14 出处:网络
I know a only little about dock panel, following is the code is used: <DockPanel LastChildFill=\"True\" >

I know a only little about dock panel, following is the code is used:

<DockPanel LastChildFill="True" >
    <StackPanel Orientation="Horizontal" DockPanel.Dock="Top" VerticalAlignment="Center" Margin="10" >
        <StackPanel Orientation="Horizontal" DockPanel.Dock="Left" VerticalAlignment="Center" >
            <TextBlock Height="24" Name="Welcome" Text="Welcome" FontSize="14" />
        </StackPanel>
        <StackPanel Orientation="Horizontal" DockPanel.Dock="Right" VerticalAlignment="Center" >
            <TextBlock Height="24" Name="Welcomee" Text="Welcomee" FontSize="14" />
        </StackPanel>
    </StackPanel>
</DockPanel>

The result is like this:

WelcomeWelcomee

However, the code must result in something like this:

Welcome                                                              Welcomee

So could you please tell me where I misunderstoo开发者_如何转开发d the concept.


Your first StackPanel should not contain the other two stack panels. It contains the other two. DockPanel.Dock="left" only applies to the immediate children of the DockPanel.

   <DockPanel>
        <StackPanel Orientation="Horizontal" DockPanel.Dock="Top" VerticalAlignment="Center" Margin="10" >Top
        </StackPanel>
        <StackPanel Orientation="Horizontal" DockPanel.Dock="Left" VerticalAlignment="Center" >
                <TextBlock Height="24" Name="Welcome" Text="Welcome" FontSize="14" />
        </StackPanel>
        <StackPanel Orientation="Horizontal" DockPanel.Dock="Right" VerticalAlignment="Center" >
               <TextBlock Height="24" Name="Welcomee" Text="Welcomee" FontSize="14" />
        </StackPanel>
    </DockPanel>
0

精彩评论

暂无评论...
验证码 换一张
取 消