根据孩子的大小扩展父级大小

时间:2013-12-07 11:47:50

标签: c# wpf resize parent-child expander

我有一个Expander位于TabItem内,位于WPF TabControl内的Window内。

我想知道如何根据扩展器大小调整所有父母的大小。

这是我的xaml,在编辑了一些不重要的项目之后。

<Window x:Name="Configurator" x:Class="Configurator.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Configuration Generator" Height="605.542" Width="566.584" Icon="radawre.png" ResizeMode="NoResize" SizeToContent="WidthAndHeight">
<Window.Resources>
    <AlternationConverter x:Key="AlternationConverter"/>
</Window.Resources>
<Grid>
    <Button x:Name="generateButton" Content="Generate" HorizontalAlignment="Left" 
            </Grid>
        </TabItem>
        <TabItem x:Name="virtTab" Header="Virtualization" >
            <Grid Background="White">

                <Expander x:Name="vadcDetailsExpander" Header="vADC Details" HorizontalAlignment="Left" Margin="452,10,-222,-18" VerticalAlignment="Top" ExpandDirection="Right" Height="404" Width="311" Collapsed="getDetailedVadc" UseLayoutRounding="False">
                    <StackPanel x:Name="vadcExpandedStackPanel" Width="229">
                        <Label x:Name="vadcCuLabel" Content="CU"/>
                        <TextBox x:Name="vadcExpandedCu"/>
                        <Label x:Name="vadcExpandedLimitLabel" Content="Throughput Limit"/>
                        <TextBox x:Name="vadcExpandedLimit"/>
                        <Label x:Name="vadcRealServersLabel" Content="Real Servers"/>
                        <TextBox x:Name="vadcExpandedRealServer"/>
                        <Label x:Name="vadcExpandedGroupsLabel" Content="Groups"/>
                        <TextBox x:Name="vadcExpandedGroups"/>

                        <WrapPanel Orientation="Horizontal">
                            <CheckBox x:Name="vadcExpendedL7" Content="L7 Enabled?" Margin="10,10,10,10" />
                            <CheckBox x:Name="vadcExpandedL3" Content="L3 Gateway?" Margin="10,10,10,10"  />
                            <CheckBox x:Name="vadcExpandedVrrp" Content="VRRP?" Margin="10,10,10,10" />
                            <GroupBox Header="VRRP Details" x:Name="expandedVrrpDetails" Height="60">
                                <StackPanel>
                                    <RadioButton x:Name="vadcExpandedMain" Content ="Main" GroupName="expandedVrrpDetails" Margin="1,1,1,1"/>
                                    <RadioButton x:Name="vadcExpandedBackup" Content="Backup" GroupName="expandedVrrpDetails" Margin="1,1,1,1"/>
                                </StackPanel>
                            </GroupBox>
                        </WrapPanel>
                        <Label x:Name="expandedVadcHealthChecksLabel" Content="Health Checks"/>
                        <ComboBox x:Name="expandedVadcHealthChecks" SelectedIndex="0">
                            <ComboBoxItem Content="icmp" ContentStringFormat="icmp"/>
                            <ComboBoxItem Content="tcp" ContentStringFormat="tcp"/>
                            <ComboBoxItem Content="http" ContentStringFormat="http"/>
                            <ComboBoxItem Content="tcphalfopen" ContentStringFormat="tcphalfopen"/>
                            <ComboBoxItem Content="httprst" ContentStringFormat="httprst"/>
                        </ComboBox>
                        <Label x:Name="expandedVadcServiceLabel" Content="Service"/>
                        <ComboBox x:Name="expandedVadcService" SelectedIndex="0">
                            <ComboBoxItem Content="HTTP" ContentStringFormat="HTTP"/>
                            <ComboBoxItem Content="FTP" ContentStringFormat="FTP"/>
                            <ComboBoxItem Content="DNS" ContentStringFormat="DNS"/>
                        </ComboBox>



                    </StackPanel>
                </Expander>
            </Grid>
        </TabItem>
    </TabControl>

</Grid>

0 个答案:

没有答案