wp7appdevelopment

Adventures in Windows Phone app development

Windows 8 (Win8 Metro): Adding a privacy policy to settings panel

Simple example of adding a handler for a privacy policy to the Settings charm in a Windows 8 (Win8 metro) app.

using Windows.UI.ApplicationSettings;

protected override void OnNavigatedTo(NavigationEventArgs e)
{
    base.OnNavigatedTo(e);

    // add handler for Privacy policy on Settings Charm
    SettingsPane.GetForCurrentView().CommandsRequested += GroupedItemsPage_CommandsRequested;
}

void GroupedItemsPage_CommandsRequested(SettingsPane sender, SettingsPaneCommandsRequestedEventArgs args)
{
    AddSettingsCommands(args);
}

public static void AddSettingsCommands(SettingsPaneCommandsRequestedEventArgs args)
{
    args.Request.ApplicationCommands.Clear();

    SettingsCommand privacyPref = new SettingsCommand("privacyPref", "Privacy Policy", (uiCommand) =>
{
Windows.System.Launcher.LaunchUriAsync(new Uri("http://www.example.com/privacy.html"));
});

    args.Request.ApplicationCommands.Add(privacyPref);
}

Leave a comment