locked
Orientation in Metro Ui RRS feed

  • Question

  • Hi , 

    I'm building a Metro UI app using C# .

    How can I find out the Orientation of my XAML page ?

    Is there any event which is triggered every time the user changes orientation ?

    Appreciate any help you could give me.

    thank you

    Monday, October 15, 2012 8:08 AM

Answers

All replies

    • Marked as answer by zakkar Monday, October 15, 2012 11:49 AM
    Monday, October 15, 2012 8:23 AM
  • Hi ,

    Yes just found it and forgot to post it.

                      

       protected override void OnNavigatedTo(NavigationEventArgs e)
            {



                DisplayProperties.OrientationChanged += OnOrientationChanged;

            }

     protected override void OnNavigatedFrom(NavigationEventArgs e)
            {
                DisplayProperties.OrientationChanged -= OnOrientationChanged;
            }

    and then the event

              

     void OnOrientationChanged(object sender)
            {

                Int32 MyWidth = 0;
        

                switch (app.CurrentOrientation)
                {
                    case DisplayOrientations.Landscape:
                      
                        break;
                    case DisplayOrientations.LandscapeFlipped:
                       
                        break;
                    case DisplayOrientations.None:
                   
                        break;
                    case DisplayOrientations.Portrait:
                        MyWidth = 800;
                        break;
                    case DisplayOrientations.PortraitFlipped:
                        
                        break;
                    default:
                   
                        break;
                }

    }

    thank you

    Monday, October 15, 2012 11:52 AM