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:
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
- <HyperlinkButton Content="Settings" FontSize="25" NavigateUri="ms-settings:"></HyperlinkButton>
Using C#
- 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:
- <ListView x:Name="settingsListBox" SelectionChanged="settingsListBox_SelectionChanged">
- <ListView.ItemsPanel>
- <ItemsPanelTemplate>
- <ItemsWrapGrid Orientation="Horizontal"> </ItemsWrapGrid>
- </ItemsPanelTemplate>
- </ListView.ItemsPanel>
- <ListView.ItemTemplate>
- <DataTemplate>
- <StackPanel Orientation="Vertical">
- <TextBlock HorizontalAlignment="Center" Text="{Binding Icon}" FontFamily="Segoe MDL2 Assets" Foreground="{ThemeResource SystemControlHighlightAccentBrush}"></TextBlock>
- <TextBlock Width="110" FontSize="22" TextWrapping="Wrap" HorizontalAlignment="Center" Text="{Binding Name}"></TextBlock>
- </StackPanel>
- </DataTemplate>
- </ListView.ItemTemplate>
- </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:
- public class Settings
- {
- public string Name
- {
- get;
- set;
- }
- public string Icon {
- get;
- set;
- }
- }
- public List < Settings > SettingList = new List < Settings > ();
- public void ShowSettings() {
- SettingList.Add(new Settings {
- Name = "Battery", Icon = "\uE8BE"
- });
- SettingList.Add(new Settings {
- Name = "Display", Icon = "\uE7F8"
- });
- SettingList.Add(new Settings {
- Name = "Data", Icon = "\uE774"
- });
- SettingList.Add(new Settings {
- Name = "Notifications", Icon = "\uE91C"
- });
- SettingList.Add(new Settings {
- Name = "Storage", Icon = "\uE8B7"
- });
- SettingList.Add(new Settings {
- Name = "Personalisation", Icon = "\uE771"
- });
- SettingList.Add(new Settings {
- Name = "Privacy", Icon = "\uE1F6"
- });
- SettingList.Add(new Settings {
- Name = "Developers", Icon = "\uEC7A"
- });
- SettingList.Add(new Settings {
- Name = "Network-wifi", Icon = "\uE905"
- });
- settingsListBox.ItemsSource = SettingList;
- }
- private async void settingsListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
- {
- var settingSelected = e.AddedItems[0] as Settings;
- await Launcher.LaunchUriAsync(new Uri("ms-settings:" + settingSelected.Name.ToLower()));
- }
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