2012-03-12 81 views
1

嗨那裏我想佈置可能App在dockpanel。 我在左邊的網格比較寬,右邊的網格很窄。我想要固定寬度的右側網格,但在我調整主窗口大小時留下了一個。這是我的XAML:DockPanel裏面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>  

這裏是行爲。恢復窗口: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>