user7494002
user7494002

Reputation:

Hide dock panel space

I want to create a window with two button, first one is fixed, the second one is in appearance and disappearance. But when the second one is hidden the window continue to allow it's space. I don't want it. How can I resolve? Thx

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

    <DockPanel Grid.Column="0">
        <Button x:Name="button" Content="Button" Width="auto" />
    </DockPanel>

    <DockPanel Grid.Column="1">
        <Button x:Name="button1" Content="Button" HorizontalAlignment="Left" Click="button1_Click" />
    </DockPanel>

</Grid>

Upvotes: 0

Views: 1526

Answers (2)

GBursali
GBursali

Reputation: 363

button1.Visibility = Visibility.Collapsed;

Difference between Hidden and Collapsed, is reserving space on your layout. Hidden reserves it, Collapsed isn't.

Upvotes: 1

Tesseract
Tesseract

Reputation: 180

Try "Collapsed" instead of "Hidden".

Upvotes: 1

Related Questions