2012-03-12 2 views
1

안녕하세요. 레이아웃을 시도하고 있습니다. Dockpanel에 App이 있습니다. 왼쪽에는 비교적 넓은 그리드가 있고 오른쪽에는 좁은 그리드가 있습니다. 고정 너비의 오른쪽 그리드가 필요하지만 메인 윈도우의 크기를 조정할 때 커지게됩니다. 여기 DockPanel 내부에 레이아웃하기

<Window 
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" 
x:Class="WebSpark.MainWindow" 
x:Name="Window" 
Title="MainWindow" 
Width="640" Height="480"> 

<DockPanel x:Name="LayoutRoot" Background="#FF474747" LastChildFill="True"> 
    <Grid DockPanel.Dock="Top" Height="23" Background="#FFEF1212" /> 
    <Grid DockPanel.Dock="Top" Height="23" Background="#FFF7E30D" /> 
    <Grid DockPanel.Dock="Left" Background="#FF0A38F1" MinHeight="396" Width="{Binding ElementName=LayoutRoot,Path=ActualWidth}" MaxWidth="428" /> 
    <Grid DockPanel.Dock="Right" HorizontalAlignment="Right" Width="198" /> 
</DockPanel>  
이 동작입니다 : 여기 내 XAML입니다. 복원 된 창 : http://s17.postimage.org/tk1pov6b3/Restored.png 최대화 된 창 : http://s9.postimage.org/457s5r23j/Maximized.png

최대화 된 창에서 볼 수 있듯이 파란색 패널이 늘어나야하지만 그렇지 않습니다. 여기 뭐가 잘못 됐니? 도와주세요. 고맙습니다.

답변

0

LastChildFill = "True"를 이용하십시오. 이 코드는 회색 상자의 크기가 고정되고 파란색 상자의 크기가 가변적임을 보장합니다.

<DockPanel x:Name="LayoutRoot" Background="#FF474747" LastChildFill="True"> 
    <Grid DockPanel.Dock="Top" Height="23" Background="#FFEF1212" /> 
    <Grid DockPanel.Dock="Top" Height="23" Background="#FFF7E30D" /> 
    <Grid DockPanel.Dock="Right" HorizontalAlignment="Right" Width="198" /> 
    <Grid DockPanel.Dock="Left" Background="#FF0A38F1" MinHeight="396" /> 
</DockPanel> 
관련 문제