Advertise with us

Remove a grid from window using WPF

Posted by  E E Cummings
 1748  View(s)
Rate this:

I have a Grid in my WPF application :

<Grid Name="MainGrid">
        <RowDefinition Height="70" Name="BarRowDef" />
        <RowDefinition Height="*"/>
    <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 Name="MiddleGrid" Grid.Row="1">
            <ColumnDefinition Width="*"/>
        <WebBrowser HorizontalAlignment="Stretch" Name="Browser" VerticalAlignment="Stretch" LoadCompleted="Finish_Load" Grid.Column="1"/>

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?

  1. Re: Remove a grid from window using WPF

    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);

      Modified On Apr-03-2018 04:52:02 AM