locked
Detecting initial viewState via javascript? RRS feed

  • Question

  • Using the simulator via Blend, I noticed that the code I'm executing on viewState change is not being executed if the simulator BEGINS in a different state - for example, in Portrait Mode. Since a lot of tablet users may actually begin the app in that mode - I was wondering how to detect the INITIAL viewState rather than a changed state?

    Thanks in advance!

    Friday, October 5, 2012 9:09 PM

Answers

  • Oops answered my own question - although perhaps it will help somebody else!

    I just used this, and posted to my statusMessage div I'm using to debug stuff:

    $(document).ready(function() {

    $('#statusMessage').html(Windows.UI.ViewManagement.ApplicationView.value); 
    if (Windows.UI.ViewManagement.ApplicationView.value == Windows.UI.ViewManagement.ApplicationViewState.fullScreenPortrait)
    {
    $('#statusMessage').html('portrait!'); 
    }
     });

    • Marked as answer by staceyreiman Friday, October 5, 2012 9:24 PM
    Friday, October 5, 2012 9:24 PM

All replies

  • Ah also this needs to be a JS solution, not CSS - as I'm running some other functions and not just applying a couple of styles for the Portrait mode.
    Friday, October 5, 2012 9:10 PM
  • Oops answered my own question - although perhaps it will help somebody else!

    I just used this, and posted to my statusMessage div I'm using to debug stuff:

    $(document).ready(function() {

    $('#statusMessage').html(Windows.UI.ViewManagement.ApplicationView.value); 
    if (Windows.UI.ViewManagement.ApplicationView.value == Windows.UI.ViewManagement.ApplicationViewState.fullScreenPortrait)
    {
    $('#statusMessage').html('portrait!'); 
    }
     });

    • Marked as answer by staceyreiman Friday, October 5, 2012 9:24 PM
    Friday, October 5, 2012 9:24 PM