expand parent size according to child size

506 views Asked by At

I have an Expander that is inside a TabItem, inside a TabControl inside a WPF Window.

I want to know how to make all the parents resize according to the expander size.

This is my xaml, after editing some items that are not really important.

<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

There are 0 answers