0

左右の列に2つのエキスパンダーを含む3つの列があります。両方のエキスパンダーが折りたたまれたとき、ウィンドウ全体の中央の列にコンテンツを配置する必要があります。そのために、グリッド長を計算する必要があります。

例えば

GridLength w1= new GridLength( 20 );
GridLength w2= new GridLength( 50 );
GridLength w3= new GridLength( 0 );

取得する方法

w3 = w2 - w1
4

1 に答える 1

1

これを試してください:拡張可能なものの幅をに設定しColumnDefinitionsAuto中央の幅を1つ星単位に設定します。内容に幅を設定して、拡張可能な列の幅を制御します。次に、それらが折りたたまれると、中央の列が拡張して使用可能なスペースを埋める必要があります。

例:

<Grid x:Name="LayoutRoot">
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="Auto"/>
        <ColumnDefinition Width="*"/>
        <ColumnDefinition Width="Auto"/>
    </Grid.ColumnDefinitions>
    <Expander Margin="0" VerticalAlignment="Top" Header="Expander" ExpandDirection="Right">
        <Grid>
            <Grid HorizontalAlignment="Left" Width="100" Background="Blue" Height="100"/>
        </Grid>
    </Expander>     
    <Expander Grid.Column="2" Margin="0" VerticalAlignment="Top" Header="Expander" ExpandDirection="Left">
        <Grid>
            <Grid HorizontalAlignment="Left" Width="100" Background="Blue" Height="100"/>
        </Grid>
    </Expander>
    <Grid Background="Aquamarine" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.Column="1" />
</Grid>

お役に立てれば

于 2009-10-14T08:01:02.083 に答える