문제

다음 코드는 두 번째 텍스트 요소가 "하단"으로 표시 되더라도 두 개의 텍스트 요소를 상단에 놓습니다. 배경색은 바닥까지 끝까지갑니다. 도크 패널이 바닥까지 늘어나는 것처럼 보입니다.

Dockpanel에 대해 무엇을 이해하지 못하는가?

<Window x:Class="TestIndexer934.Views.MainView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:c="clr-namespace:TestIndexer934.Commands"
    Title="Main Window" Height="400" Width="800">
    <DockPanel HorizontalAlignment="Left" Background="Beige">
        <TextBlock DockPanel.Dock="Top" Text="Testing top"/>
        <TextBlock DockPanel.Dock="Bottom" Text="Testing bottom"/>
    </DockPanel>
</Window>
도움이 되었습니까?

해결책

에 의해 기본 DockPanel의 마지막 항목은 나머지 콘텐츠 영역을 채우게됩니다.

설정하면 LastChildFill="False" DockPanel에서는 당신이 기대하는 행동을 볼 수 있습니다. 당신은 또한 설정할 수 있습니다 VerticalAlignment="Bottom" 텍스트 블록에서.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top