Search code examples
c#windows-phone-8alignmentwebbrowser-controlapplication-bar

ApplicationBar with minimized mode override WebBrowser component at landscape orientation


Application Bar override web browser

i have been read some similar questions on Stackoverflow but cannot make it works correctly Here is my WebBrowser XAML code

<phone:WebBrowser Name="webBrowser" 
                  ScriptNotify="webBrowser_ScriptNotify" 
                  IsScriptEnabled="True" 
                  Margin="0" 
                  Background="Transparent"
                  HorizontalAlignment="Stretch"
                  VerticalAlignment="Stretch">

and Application Bar in code

void BuildAppBar()
{
    ApplicationBar = new ApplicationBar();
    ApplicationBar.Mode = ApplicationBarMode.Minimized;
    ...
 }

Solution

  • This happens when you have set the Mode Property of ApplicationBar to Minimized (i don't know why), so what you can do is to use OrientationChanged event of the page to set the Mode Property:

    private void PhoneApplicationPage_OrientationChanged(object sender, OrientationChangedEventArgs e)
    {
        if (e.Orientation == PageOrientation.PortraitUp)
        {
            this.ApplicationBar.Mode = ApplicationBarMode.Minimized;
        }
        else
        {
            this.ApplicationBar.Mode = ApplicationBarMode.Default;
        }
    }