how to know if the app is in portrait, landscape or snap view state?


  •   How to know if the app is running in portrait, landscape or snap view state?
    Thursday, May 30, 2013 2:02 AM


All replies

  • You can use the Windows.UI.ViewManagement.ApplicationView.value. The value is ApplicationViewState enum which can give you the current view state.

    See this post on how to determine the view state for different resizing.

    - Girija

    Please mark responses as answered if it helped you.. This helps others... - Girija Shankar Beuria

    • Marked as answer by SonalMac Thursday, May 30, 2013 6:19 AM
    Thursday, May 30, 2013 2:26 AM
  •   This answer definitely works on "resize" event. That means it captures viewState when changing app from one viewstate to another.

      But I also want to capture viewstate the first time the app launches.  How to do that?

    Thursday, May 30, 2013 9:22 PM
  •   I got it.  We have to use this function when app launches. Call the function under these statements:

    if (args.detail.kind === activation.ActivationKind.launch) {
                if (args.detail.previousExecutionState !== activation.ApplicationExecutionState.terminated) {
                    // TODO: This application has been newly launched. Initialize
                    // your application here.
                    updateLayout();  //Your code to work on viewstate 

    • Proposed as answer by Ramya SJ Thursday, June 13, 2013 1:51 PM
    Thursday, May 30, 2013 9:29 PM