WPF StackPanel大小

时间:2016-07-04 12:54:44

标签: wpf stackpanel groupbox

我有以下wpf窗口。 为什么StackPanel没有采用GroupBox的大小? 如何强制它自动获取GroupBox的大小?

谢谢

XAML

  <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"
            xmlns:local="clr-namespace:StyleTrigger"
            xmlns:local2="clr-namespace:ComboBoxData"
            xmlns:sys="clr-namespace:System;assembly=mscorlib"
            xmlns:ig="http://schemas.infragistics.com/xaml" x:Class="StyleTrigger.MainWindow"
            mc:Ignorable="d"
            Title="MainWindow" Height="350" Width="525">


        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="50*" />
                <ColumnDefinition Width="50*"/>
            </Grid.ColumnDefinitions>


            <Grid.RowDefinitions>
                <RowDefinition Height="1*"/>
                <RowDefinition Height="1*"/>
                <RowDefinition Height="1*"/>
            </Grid.RowDefinitions>

            <GroupBox x:Name="groupBox" Header="GroupBox" Grid.Row="1"  >
                <StackPanel  HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                    <TextBox />
                    <TextBox />
                </StackPanel>
            </GroupBox>

        </Grid>
    </Window>

0 个答案:

没有答案