How to add a Privacy Policy Link to Settings C#

I had trouble trying to add a link to my privacy policy to my settings flyout in my C# XAML app, so I put my solution here.

First add these using directives to App.XAML.cs:

using Windows.UI.ApplicationSettings;
using Windows.UI.Popups;

Second under OnLaunched in App.xaml.cs under #endif put:

SettingsPane.GetForCurrentView().CommandsRequested +=   SettingCharmManager_CommandsRequested;

Third, add these 2 methods to App.xaml.cs:

private async void OpenPrivacyPolicy(IUICommand command)
        {
            Uri uri = new Uri(“http://yourprivacypolicyURL”);
            await Windows.System.Launcher.LaunchUriAsync(uri);
        }

private void SettingCharmManager_CommandsRequested(SettingsPane sender, SettingsPaneCommandsRequestedEventArgs args)
        {
            args.Request.ApplicationCommands.Add(new SettingsCommand(“privacypolicy”,  “Privacy policy”, OpenPrivacyPolicy));
        }

 

Hope this was helpful.

Leave a Reply

Your email address will not be published. Required fields are marked *