OrientationChanged: Windows Phone vs Windows Store RRS feed

  • Question

  • I have a Universal App in which I want to handle the OrientationChanged event. I do this using the following in the constructor as follows:
    AddHandler DisplayInformation.GetForCurrentView().OrientationChanged, AddressOf Me.DisplayInformation_OrientationChanged
    In Windows Phone, this event is called if the app is opening in landscape or landscape flipped, but not when it opens in portrait. I am assuming that this is because phone apps are usually designed for portrait orientation. But in Windows Store apps, the event is not called regardless of what orientation it opens in. It is not hard to find a workaround for this, but it does reduce the amount of code that will be the same between the Windows Phone and Windows Store versions of the apps. Why do Windows Phone and Windows Store apps treat the OrientationChanged event differently when opening? Thanks.

    Nathan Sokalski njsokalski@hotmail.com http://www.nathansokalski.com/

    Saturday, November 1, 2014 7:07 PM


  • OrientationChanged does not fire in the simulator.
    Monday, November 3, 2014 7:03 AM

All replies

  • Hi Nathan,

    Thank you for raising this question, as we can see the documentation:OrientationChanged | orientationchanged event

    The OrientationChanged event occurs only when orientation of the display or monitor changes and not necessarily when the orientation of your app changes.

    I don't know how you manage the orientationChanged event in Windows Store and Windows Phone, but the event is only fired with device orientation rotation.

    Let's say if we wrote the code in page constructor, the event is registered after the UIElement of the page initialized, and if currently the AutoRotationPreferences is Landscape, you could not see the event fired with Windows Phone but not Windows Store App, because the default setting of Windows Phone is portrait but default of Windows Store device is Landscape.

            public MainPage()
                DisplayInformation.GetForCurrentView().OrientationChanged += MainPage_OrientationChanged;
            void MainPage_OrientationChanged(DisplayInformation sender, object args)
                throw new NotImplementedException();


    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Monday, November 3, 2014 2:32 AM
  • I think you may pre-settings your app 

    Rotation is a touch optimized technique using which user can rotate an app in a circular direction [clockwise / anti-clockwise]. Each Windows Store App template type in Visual Studio 2012 was designed to support multiple rotations. The Application UI tab inpackage.appxmanifest file contains a ‘Supported rotations’ section, using which you can select the rotations you need your app to support.

    This is one of the most important step during application design. Some of the apps [for e.g. a game app] may not look better in Portrait mode, in that case you can just check the Landscape rotation option. However for apps like blog reader, you might need to support all the rotations.

    Monday, November 3, 2014 7:01 AM
  • OrientationChanged does not fire in the simulator.
    Monday, November 3, 2014 7:03 AM