question

dovholuknf-1897 avatar image
0 Votes"
dovholuknf-1897 asked ·

Show MainPage.xaml from "VPN Client" UWP app

UWP allows for the definition of "custom vpn plugins" by adding the "networkingVpnProvider" Capability. When one goes to "Network & Internet" -> "VPN" and clicks "connect" the application containing the background task will launch. If that application has a UI - one can also view the UI by starting the application from start -> "name of app".

That's all great - what I'd like to do since this is a VPN I'd like the UI to pop up when the user clicks the "Connect" button. I can't find the right API to pop up the "MainPage" associated with a background task. I also can't pass a pass a reference into the background task since it's windows itself that's starting it...

Hopefully this is doable. Thanks in advance for any help.

uwp
· 2
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Based on the comment you posted, do you mean that you want to bring the main window of the app into the foreground when it is not in the foreground?

0 Votes 0 · ·

Yes that's correct.

0 Votes 0 · ·
pesmithredmond avatar image
0 Votes"
pesmithredmond answered ·

You can have a certain amount of UI elements be displayed by using the various VpnCustom* items. For example, use VpnCustomPrompt to prompt the user for a value. You can't show arbitrary UI.

As you probably already know, the vpnNetworkProvider capability is restricted; not all companies will get it.

· 1 · Share
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

I am not looking for an arbitrary UI - i'm looking for the MainPage.xaml that ships with the UWP app itself. The format of the UWP project is "main app (UWP UI)" and "background task" library. When the VPN plugin is connected using the VPN settings panel an instance of the exe is fired up but it's hidden. I've tried to get creative with getting a reference to the MainPage but I've not found the proper incantations to get the UI to fire up.

Since it's a VPN client - I'd really like to be able to tell the user that it's running and it connected properly. Allow them to toggle it on and off etc.

Thanks

0 Votes 0 · ·
RoyLi-MSFT avatar image
0 Votes"
RoyLi-MSFT answered ·

Hello,

Welcome to Microsoft Q&A!

Yes, there is a way to bring the UWP app to the foreground. It's called CompactOverlay mode. But I don't think that is suitable for your scenario. If you just want to let the customer know that the app is connected and it's running correctly, you could try another way by sending a local toast notification to the user. Then if the user click the notification, it could launch your app.

For more information about sending notifications, please refer to: Send a local toast notification

Thank you

· Share
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.