2009-07-29 9 views
1

Dans mon Shell.xaml, je veux que deux modules prennent la moitié de la hauteur et soient extensibles. Pourquoi le premier module est-il coupé?Pourquoi mes modules ne remplissent-ils pas le DockPanel complet dans mon Shell.xaml?

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

Shell:

<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> 

Répondre

1

Permettez-moi de répondre à cette question. J'ai utilisé un Grille avec des hauteurs de rangée variables et cela a fonctionné.

<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> 

Aussi étrange que cela StackPanel et DockPanel ne divise pas automatiquement leur espace à parts égales. StackPanel n'élargit pas ses enfants pour remplir l'espace disponible (c'est une caractéristique)

+0

Vous n'avez pas besoin de 5 dans Height = "5 *", utilisez simplement * dans les deux lignes. – Carlo

0

DockPanel se étire si vous utilisez LastChildFill="true"

Questions connexes