2009-07-29 6 views
1

私のShell.xamlでは、2つのモジュールがそれぞれ高さの半分を占めて拡張可能であることを望みます。なぜ最初のモジュールが切断されていますか?私のモジュールが私のShell.xaml内の完全なDockPanelを満たさないのはなぜですか?

alt text http://i30.tinypic.com/2cr5zx0.png

シェル:

<Window x:Class="HelloWorld.Desktop.Shell" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:cal="http://www.codeplex.com/CompositeWPF" 
     Height="300" 
     Width="300" 
     Title="Hello World" > 

    <DockPanel LastChildFill="True"> 
     <ContentControl Name="MainRegion" 
         DockPanel.Dock="Top" 
       cal:RegionManager.RegionName="MainRegion"/> 
     <ContentControl 
      Name="SecondRegion" 
      DockPanel.Dock="Top" 
      cal:RegionManager.RegionName="SecondRegion"/> 
    </DockPanel> 
</Window> 

HelloWorldView:

<UserControl x:Class="HelloWorldModule.Views.HelloWorldView" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> 
    <StackPanel 
      Background="Tan"> 
     <TextBlock Text="Hello World View" 
        Foreground="Brown" 
        Margin="10 10 10 0" 
        FontSize="14"/> 

     <TextBlock Name="DisplayArea" 
       Margin="10 10 10 0" Text="(default text)" TextWrapping="Wrap"/> 
    </StackPanel> 
</UserControl> 

SecondView:

<UserControl x:Class="SecondModule.Views.SecondView" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> 
    <StackPanel 
      Background="Orange"> 
     <TextBlock Text="Second View" 
        Foreground="Brown" 
        Margin="10 10 10 0" 
        FontSize="14"/> 

     <TextBox Name="Message" 
       Margin="10 10 10 0" Text="skfddsf" TextChanged="TextBox_TextChanged"/> 
    </StackPanel> 
</UserControl> 

答えて

1

私はこれに答えることができます。可変幅の高さでグリッドを使用していました。

<Grid> 
    <Grid.RowDefinitions> 
     <RowDefinition Height="5*"/> 
     <RowDefinition Height="5*"/> 
    </Grid.RowDefinitions> 
    <ContentControl Name="MainRegion" 
        Grid.Row="0" 
      cal:RegionManager.RegionName="SecondRegion"/> 
    <ContentControl 
     Name="SecondRegion" 
        Grid.Row="1" 
     cal:RegionManager.RegionName="MainRegion"/> 
</Grid> 

奇妙なことのStackPanelDockPanelが自動的に均等に自分のスペースを分割しませんが。

+0

実際には5インチの高さ= "5 *"は必要ありません。両方の行に*を使用するだけです。 – Carlo

0

StackPanelは、使用可能な領域を埋めるために子を伸ばしません(これは機能です)。

LastChildFill="true"を使用すると、DockPanelが伸縮します。

関連する問題