Agile Hobo
Agile Hobo

Reputation: 322

How to check a Windows Store app on the left or right of screen when it's in snapped state?

I want to check position of a Windows Store app when it's in snapped state (left or right of the screen) by code. If it's on the left, I do something. If it's on the right, I do something else.

How to do it?

Upvotes: 1

Views: 462

Answers (2)

Mayank
Mayank

Reputation: 8852

I don't think you can detect which side the App is snapped to. You can detect if app is snapped, filled, FullScreenLandscape and FullScreenPortrait and that's about it.

Windows.UI.ViewManagement namespace doesn't provide any function for position of snapped state.

Update

As Jim O'Neil said, following code works perfectly.

if (Windows.UI.ViewManagement.ApplicationView.Value == Windows.UI.ViewManagement.ApplicationViewState.Snapped)
{
    if (Window.Current.Bounds.Left == 0)
        // snapped left
    else
        // snapped right
}

Upvotes: 0

Jim O'Neil
Jim O'Neil

Reputation: 23754

Check the Left edge of the Current window in conjunction with the ApplicationView

if (Windows.UI.ViewManagement.ApplicationView.Value == Windows.UI.ViewManagement.ApplicationViewState.Snapped)
{
    if (Window.Current.Bounds.Left == 0)
        // snapped left
    else
        // snapped right
}

Upvotes: 2

Related Questions