본문 바로가기

.NET/WPF

WPF 기초 DockPanel 선언 순서가 중요하다

반응형


<Page
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  <DockPanel LastChildFill="True">

    <TextBlock DockPanel.Dock="Left" VerticalAlignment="Center">
    I am the left...
    </TextBlock>
    <TextBlock DockPanel.Dock="Right" VerticalAlignment="Center">
    I am the Right
    </TextBlock>
        <TextBlock DockPanel.Dock="Top" Background="LightCoral" >
    I am the top...
    </TextBlock>
    <TextBlock DockPanel.Dock="Bottom" Background="LightCoral">
    I am the bottom
    </TextBlock>
    <Button Height="40" Width="200">I am the Fill(of the center)</Button>
    
  </DockPanel>
</Page>





<Page
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  <DockPanel LastChildFill="True">
        <TextBlock DockPanel.Dock="Top" Background="LightCoral" >
    I am the top...
    </TextBlock>
    <TextBlock DockPanel.Dock="Bottom" Background="LightCoral">
    I am the bottom
    </TextBlock>
    <TextBlock DockPanel.Dock="Left" VerticalAlignment="Center">
    I am the left...
    </TextBlock>
    <TextBlock DockPanel.Dock="Right" VerticalAlignment="Center">
    I am the Right
    </TextBlock>

    <Button Height="40" Width="200">I am the Fill(of the center)</Button>
    
  </DockPanel>
</Page>




<Page
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  <DockPanel LastChildFill="True">
        <TextBlock DockPanel.Dock="Top" Background="LightCoral" >
    I am the top...
    </TextBlock>
    <TextBlock DockPanel.Dock="Bottom" Background="LightCoral">
    I am the bottom
    </TextBlock>
    <TextBlock DockPanel.Dock="Left" VerticalAlignment="Center">
    I am the left...
    </TextBlock>
    <Button Height="40" Width="200">I am the Fill(of the center)</Button>
    
    <TextBlock DockPanel.Dock="Right" VerticalAlignment="Center">
    I am the Right
    </TextBlock>
    
  </DockPanel>
</Page>



- 출처  Programming .Net 3.5 by Jesse Liberty and Alex Horovitz. (소수 수정)