Question

So I recently upgraded and started updating my app for Windows 8.1 With the AplicationViewState being deprecated, I am having a problem getting the current size of the app to determine which layout should be loaded. When I change the size of the app after the page is open, I am able to load the layout I need. But when I navigate to the next page, it just loads the default view (which is landscape) no matter if the app is snapped or not. I am subscribed to the WindowSizeChanged event to handle changes, but I cant seem to grab the size when first navigating to the page.

This is an example of how I am handling the size change inside the app

void WindowSizeChanged(object sender, WindowSizeChangedEventArgs e)
    {
        if (e.Size.Width < e.Size.Height + 100)
        {
            VisualStateManager.GoToState(this, "Portrait", true);
        }

        else
        {
            VisualStateManager.GoToState(this, "Landscape", true);
        }
    }

Thanks in advance!

Was it helpful?

Solution

Found out what I was doing wrong. The VisualStateMnager on the xaml page was outside of the grid control. Once I placed it into the Grid Control it worked just fine.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top