0

一番下のテキストブロックで残りのスペースを水平および垂直に埋めるにはどうすればよいですか?

代替テキスト

この領域を持つシェルがあります:

<DockPanel Grid.Column="0" Grid.Row="2" Grid.ColumnSpan="2" LastChildFill="True"  
Background="Orange">

    <ItemsControl x:Name="MainNavigationPanel" 
        Background="Yellow"
        DockPanel.Dock="Left"
        cal:RegionManager.RegionName="MainNavigationPanel"
            Width="200" 
            HorizontalAlignment="Left"/>


    <StackPanel x:Name="MainContent"
        Background="Beige"
        Width="Auto"
        Height="Auto"
        VerticalAlignment="Stretch"
        HorizontalAlignment="Stretch"
        >
        <TextBlock Text="This will be the main region content."/>
        </StackPanel>

</DockPanel>

MainNavigationPanelでは、次のビューを読み込みます。

<UserControl x:Class="MenuModule.Views.MainNavigationView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:igOB="http://infragistics.com/OutlookBar"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    VerticalAlignment="Stretch" 
    HorizontalAlignment="Stretch">

    <DockPanel LastChildFill="True"
        Background="Red"
        HorizontalAlignment="Left"
        VerticalAlignment="Stretch">

            <TextBlock Text="first" 
            DockPanel.Dock="Top"
            Background="LightBlue"
            VerticalAlignment="Stretch"
            HorizontalAlignment="Stretch"/>

            <TextBlock Text="second" 
            DockPanel.Dock="Bottom"
            Background="LightGreen"
            VerticalAlignment="Stretch"
            HorizontalAlignment="Stretch"/>

    </DockPanel>

</UserControl>
4

1 に答える 1

2

Dockpanelは、DockPanel.Dock添付プロパティが指定されておらず、高さ/幅が指定されていない最後のアイテムで残りのスペースを自動的に埋めます。

ここで提供したサンプルは、Shell.Xamlでこの手法を示しています。 モジュールがメニューに読み込まれるPrismの例を探しています

この事実は、MSDNドキュメントのDockPanelの「備考」セクションにあります:MSDNのDockPanel

于 2009-07-22T15:34:11.260 に答える