YosiFZ
YosiFZ

Reputation: 7900

WPF remove grid from window

I have this Grid in my WPF application :

<Grid Name="MainGrid">

    <Grid.RowDefinitions>
        <RowDefinition Height="70" Name="BarRowDef" />
        <RowDefinition Height="*"/>
    </Grid.RowDefinitions>

    <Grid Name="BarGrid" Grid.Row="0" Height="70" VerticalAlignment="Top" Background="#FF802C2C">
        <Button Content="History" Focusable="False" Width="100" Height="60" HorizontalAlignment="Left" VerticalAlignment="Center" Name="HistoryButton" Click="HistoryButton_Click"/>
    </Grid>

    <Grid Name="MiddleGrid" Grid.Row="1">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>
        <WebBrowser HorizontalAlignment="Stretch" Name="Browser" VerticalAlignment="Stretch" LoadCompleted="Finish_Load" Grid.Column="1"/>
    </Grid>


</Grid>

And i want to the browser will have full screen option. So what i done is in the event Of EnterFullscreen is called is :

BarRowDef.Height = new GridLength(0);

And what happen is that the Browser start from the top of the page but in the bottom i have a white space in the size of BarGrid. Any idea what can be the problem?

Edit

This is the full EnterFullScreenMode method :

public void EnterFullScreenMode()
    {
        BarRowDef.Height = new GridLength(0);

        if (this.WindowState == System.Windows.WindowState.Maximized)
        {
            this.WindowState = System.Windows.WindowState.Normal;
        }

        this.WindowStyle = System.Windows.WindowStyle.None;
        this.WindowState = System.Windows.WindowState.Maximized;

        IsFullScreen = true;
    }

Upvotes: 0

Views: 546

Answers (2)

Daniel
Daniel

Reputation: 5389

I believe setting to Visibility.Hidden can still result in some whitespace being rendered.

You can set the content of the row (BarGrid) to Collapsed, which means: "Do not display the element, and do not reserve space for it in layout".

BarGrid.Visibility = Visibility.Collapsed;

Edit: Additional details from comments

Also ensure the height setting removed from the RowDefinition. Instead of:

<RowDefinition Height="70" Name="BarRowDef"/>

Use:

<RowDefinition Height="Auto"/>

Upvotes: 2

Tafari
Tafari

Reputation: 3089

I am not sure what do you mean, EnterFullscreen event of what?

You can try this:

BarGrid.Visibility = Visibility.Hidden;

instead of:

BarRowDef.Height = new GridLength(0);

Upvotes: 1

Related Questions