Force WinRT app to snapped view - windows-8

For one of my apps I'd like to send the app to snapped view after tapping a button. As far as I know there's no public API available to send a running application to snapped view. Did anyone find a workaround to do this?
Somehow it should be possible since you're able to do it in Windows 8 itself, and snap one of the running apps.
Update: Being able to trigger a Win+. might do the same trick, but the SendKeys API isn't available in WinRT either.

There is no way to force an application into snapped mode - it has to be a user initiated action.
An application can request to be unsnapped through:
Windows.UI.ViewManagement.ApplicationView.TryUnsnap();
Which tries to push the app into fill mode.

Windows 10 has a ApplicationView.TryResizeView method
So... to summarize the interesting WinRT journey:
Windows 8
Has a a 'Snapped' mode that a only a user can initiate. the developer can try to unsnap with the TryUnsnap method
Windows 8.1
Does not have Snapped mode, and TryUnsnap is deprecated. The dev can still listen for window size changes and know if the app view is in a smaller size as before.
Windows 10
Introduced the ApplicationView.TryResizeView method, where the dev can try to resize. Window size changed event is still there.
ApplicationView.GetForCurrentView().TryResizeView(new size(width, height)));

Related

UWP transparent window

I realize something like this has been asked before, but I would like to create an app with UI elements atop a transparent window (basically, an app without a window frame and with transparent background).
I've read the following posts:
transparent app in windows 10 uwp
Transparent UWP windows 10
I checked the BlurPlayground.
It seems that this isn't possible. However, the Sticky Notes application in Windows 10 is definitely managing to do this. Either this is some special API only available to Microsoft, or it can be done.
Can someone confirm?
This cannot be done in UWP today. The custom frame you see in Sticky Notes is a one-off implementation that does not have a public API.
Curious what is your scenario you want to accomplish here? (feel free to ping me offline - swick [at] Microsoft.com)
Thanks,
Stefan Wick - Windows Developer Platform

WP8: Can this (PhoneApplicationService.RunningInBackground ) be used outside of location based app?

From this link below, it seems that your app can still get event when app is switched to background. But it seems it is used only for location based app. Can normal app do that? I had tried to declare ID_CAP_LOCATION but still Application_RunningInBackground not get called when switch to background.
http://msdn.microsoft.com/en-us/library/windowsphone/develop/microsoft.phone.shell.phoneapplicationservice.runninginbackground(v=vs.105).aspx
The app doesn't execute in background, unless it is continously tracking the location.
This section lists the conditions under which the operating system
will deactivate an app running in the background....
The app stops actively tracking location. An app stops tracking location by removing event handlers for the PositionChanged and
StatusChanged events of the Geolocator class or by calling the Stop()
method of the GeoCoordinateWatcher class.
Source: Running location-tracking apps in the background for Windows Phone 8
You will find complete info of how to run apps in background here:
How to run location-tracking apps in the background for Windows Phone 8

How to find out user is at desktop instead of start screen or another store app UI at Windows 8

As we know, at windows 8 if user is at start screen or another store app (metro app) UI, the dialog at the desktop won't be visible to user. We are adding some toast notification capability at our application by following Sending toast notifications from desktop apps sample. I am able to get it working. However if user is already at the desktop, we don't want to send out the toast notification. So it would mean that we need to be able to detect if user is current at desktop or not. Somehow I didn't find any API by searching on internet. Could someone let me know how to do so? Thanks very much.
A toast notification can't know in what context the user is located, so this is not possible.

WinRt WebView control handling navigation within the control

I have a Metro app using a WebView control. I'm using NavigateToString to load a html file which may contain hyperlinks. What I then want to do is detect when one of these hyperlinks is selected and, instead of allowing navigation within the WebView control, to launch IE and view the page there instead.
Is this possible within the WinRT constraints, and if so, how?
So far, I've tried capturing the WebView_LoadCompleted() event, but although it does fire at the right time, I can't see any details about the URI from the NavigationEventArgs.
Unfortunately this isn't possible directly because WebView does not include events like Navigating (which were present in Windows Phone).
Luckily Nick Randolph (brilliant Windows Phone and Windows 8 developer) has created a workaround using script events. He's got a great write up on his blog:
http://nicksnettravels.builttoroam.com/post/2012/04/21/Limitations-of-the-WebView-in-Windows-8-Metro-Apps.aspx

How to use AssistiveTouch UI in iOS

I'm now developing an app on iOS. With some reason, I want to use AssistiveTouch UI in my app. For example, there will display a button in my app like AssistiveTouch, if anyone press this button, four buttons will appear like AssistiveTouch, if anyone press one of there four buttons again, some action i set before will excuse.
Does apple support api about this? Or Is there any source code available?
You would have to reimplement this from scratch. There is no public API for either accessing the existing Assistive Touch feature (it has to be turned on by the user in the settings) or for creating a similar UI.