2009-07-29 64 views
1

在我的Shell.xaml中,我希望兩個模塊各佔用一半高度並可擴展。爲什麼第一個模塊被切斷?爲什麼我的模塊不能填充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> 
    <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> 

奇怪儘管這StackPanel中DockPanel中不會自動將其向上的空間也同樣。

+0

您實際上不需要Height =「5 *」中的5,只需在兩行中使用*即可。 – Carlo 2009-07-30 19:40:49

0

StackPanel不會伸展它的子項以填充可用空間(這是一項功能)。

如果您使用LastChildFill="true",DockPanel會拉伸。

相關問題