How To Launch The Windows Settings From Your Application In Windows 10 UWP APP

LaunchUriAsync starts the default app, associated with the URL scheme.

To launch the Settings app, use the MS-settings

We can do this in two ways:

  • Using XAML
  • Using C#

Let’s see the steps.

Create new Windows 10 universal app and write the following XAML code to launch the settings option in your app.

Using XAML

  1. <HyperlinkButton Content="Settings" FontSize="25" NavigateUri="ms-settings:"></HyperlinkButton>  
Using C#
  1. Launcher.LaunchUriAsync(new Uri("ms-settings:"));  
In some privacy settings, the operating system will prompt the user to actually want to switch the apps.

List of uri scheme.
 

Category

Settings

URI

Home Page

Settings landing page

ms-settings:

System

Display

ms-settings:screenrotation

 

Notifications & actions

ms-settings:notifications

 

Battery Saver

ms-settings:batterysaver

 

Battery Saver / Battery use

ms-settings:batterysaver-usagedetails

 

Power & sleep

ms-settings:powersleep

 

Desktop: About

ms-settings:deviceencryption

 

Offline Maps

ms-settings:maps

 

About

ms-settings:about

Devices

Default camera

ms-settings:camera

 

Bluetooth

ms-settings:bluetooth

 

Mouse & touchpad

ms-settings:mousetouchpad

Network & Wireless

Wi-Fi

ms-settings:network-wifi

Network & Internet

Data usage

ms-settings:datausage

Personalization

Personalization (category)

ms-settings:personalization

 

Background

ms-settings:personalization-background

Accounts

Your email and accounts

ms-settings:emailandaccounts

 

Work access

ms-settings:workplace

 

Sync your settings

ms-settings:sync

Time and language

Date & time

ms-settings:dateandtime

 

Region & language

ms-settings:regionlanguage

Ease of Access

Narrator

ms-settings:easeofaccess-narrator

 

Magnifier

ms-settings:easeofaccess-magnifier

 

High contrast

ms-settings:easeofaccess-highcontrast

Privacy

Location

ms-settings:privacy-location

 

Camera

ms-settings:privacy-webcam

 

Microphone

ms-settings:privacy-microphone

 

Account info

ms-settings:privacy-accountinfo

Update & security

Developers

ms-settings:developers

Now, we are going to see, how to list the settings with the icon in your app. Here, I am going to create one list view to list the settings with icon and the XAML code looks like the following code:

  1. <ListView x:Name="settingsListBox" SelectionChanged="settingsListBox_SelectionChanged">  
  2.     <ListView.ItemsPanel>  
  3.         <ItemsPanelTemplate>  
  4.             <ItemsWrapGrid Orientation="Horizontal"> </ItemsWrapGrid>  
  5.         </ItemsPanelTemplate>  
  6.     </ListView.ItemsPanel>  
  7.     <ListView.ItemTemplate>  
  8.         <DataTemplate>  
  9.             <StackPanel Orientation="Vertical">  
  10.                 <TextBlock HorizontalAlignment="Center" Text="{Binding Icon}" FontFamily="Segoe MDL2 Assets" Foreground="{ThemeResource SystemControlHighlightAccentBrush}"></TextBlock>  
  11.                 <TextBlock Width="110" FontSize="22" TextWrapping="Wrap" HorizontalAlignment="Center" Text="{Binding Name}"></TextBlock>  
  12.             </StackPanel>  
  13.         </DataTemplate>  
  14.     </ListView.ItemTemplate>  
  15. </ListView>  
For showing icon change, go to the Font Family and “ Segoe MDL2 Assets “.

Now, go to code at the backend and create the list of the settings with the icon, using the code, given below:
  1. public class Settings  
  2. {  
  3.     public string Name   
  4.   {  
  5.         get;  
  6.         set;  
  7.     }  
  8.     public string Icon {  
  9.         get;  
  10.         set;  
  11.     }  
  12. }  
  13. public List < Settings > SettingList = new List < Settings > ();  
  14. public void ShowSettings() {  
  15.     SettingList.Add(new Settings {  
  16.         Name = "Battery", Icon = "\uE8BE"  
  17.     });  
  18.     SettingList.Add(new Settings {  
  19.         Name = "Display", Icon = "\uE7F8"  
  20.     });  
  21.     SettingList.Add(new Settings {  
  22.         Name = "Data", Icon = "\uE774"  
  23.     });  
  24.     SettingList.Add(new Settings {  
  25.         Name = "Notifications", Icon = "\uE91C"  
  26.     });  
  27.     SettingList.Add(new Settings {  
  28.         Name = "Storage", Icon = "\uE8B7"  
  29.     });  
  30.     SettingList.Add(new Settings {  
  31.         Name = "Personalisation", Icon = "\uE771"  
  32.     });  
  33.     SettingList.Add(new Settings {  
  34.         Name = "Privacy", Icon = "\uE1F6"  
  35.     });  
  36.     SettingList.Add(new Settings {  
  37.         Name = "Developers", Icon = "\uEC7A"  
  38.     });  
  39.     SettingList.Add(new Settings {  
  40.         Name = "Network-wifi", Icon = "\uE905"  
  41.     });  
  42.     settingsListBox.ItemsSource = SettingList;  
  43. }  
  44. private async void settingsListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)  
  45. {  
  46.     var settingSelected = e.AddedItems[0] as Settings;  
  47.     await Launcher.LaunchUriAsync(new Uri("ms-settings:" + settingSelected.Name.ToLower()));  
  48. }  
On selection changed event, I am getting the settings menu name. Convert it to the lowercase to set the correct URL. Using the LaunchUriAsync method, we can launch the corresponding setting.

Now, run the app and check the output

 


Similar Articles