codefoster | Try Unsnap
Jeremy Foster
@codefoster

Try Unsnap

by Jeremy Foster 26. October 2012 13:32

Here’s a tidbit that is easy to miss if you’re not looking for it.

If your user has snapped your app, but then they take an action in your app that gives you reason to attempt to get back out of snap mode, you can do so by calling…

Windows.UI.ViewManagement.ApplicationView.tryUnsnap();

This method returns  a value of true if it has successfully been unsnapped or false if it was not able to. It’s only going to unsnap for you if your app is in the foreground.

I’m using this method in my codeSHOW project. If the user snaps codeSHOW and then attempts to browse to one of the demos, then codeSHOW will unsnap itself to allow that demo to run full screen.

Hope that helps.

*** See important comment from Jerry Nixon below: the tryUnsnap() method will not work if it's called from code that is not user initiated. Thanks, Jerry. ***

Tags:

JavaScript | Windows 8 | WinRT

Comments (2) -

Jerry Nixon
Jerry Nixon United States
5/7/2013 7:43:38 PM #

Jeremy, I wanted to add a bit of detail to this. This API will not work inside events that are raised programmatically. That is, events like a timer tick or page pipeline events like Loaded. This API bust be called by user-initiated events like Button.Click. Otherwise the code will not result in an error - they just will not work. A developer can pull his hair out if he doesn't know this detail. I am astonished not to see mention of this in MSDN docs. But, now CodeFoster has it! Thanks for the article, Jeremy. Top shelf. // Jerry

ref: http://stackoverflow.com/a/16427190/265706

Reply

jeremy
jeremy United States
5/17/2013 4:41:49 PM #

Great. Thanks, Jerry.

Reply

Add comment

  Country flag

biuquote
  • Comment
  • Preview
Loading

Feed Subscribe