Search code examples
c#wpfvisual-studio

Opening ms-settings from WPF application


<--------------EDIT:-------------->

I can't use Windows.System

That assembly (and associated classes and namespaces) are for Windows Store apps only.

You cannot use them in a standard C# project.

Reference on MSDN.

Also, the first part of the question has been answered:

If it sounds simple, it is.

Process.Start("ms-settings:SomePage");

So, now the question is, how do you get that to launch inside the WPF Page/Window?

<--------------/EDIT-------------->

I am using Visual Studio 2015 to develop a WPF application. I'd prefer to use C# to launch the ms-settings:whatever page.

Ok, so I'm trying to follow the directions listed HERE on msdn.microsoft, but the assembly they reference "Windows.System" doesn't seem to exist. 0.o

"System.Windows" exists, but it doesn't contain Launcher.LaunchUriAsync...

Below is the snippet of code on that page:

using Windows.System;
...
bool result = await Launcher.LaunchUriAsync(new Uri("ms-settings:privacy-webcam"));

So the question is, what am I missing? I'm pretty sure something is flying way over my head and I can't seem to see what is.

Bonus points if you know how to get the ms-settings app to open inside the WPF page, although I'm pretty sure that isn't reasonably feasible.


Solution

  • It seems that Windows treats the ms-settings:... syntax as URI. So, you should be able to open it in the default browser just as you would open any other URI from within C# code:

    System.Diagnostics.Process.Start("ms-settings:privacy-webcam");
    

    However, I'm not sure how older versions of Windows (which don't know the ms-settings:... syntax) react to that...