Adding a Privacy Policy to your Application + About Page using the Settings Charm

After developing your windows 8 application here is one of the most important things to add to your application which is the Privacy Policy.

What is a Privacy Policy ?

Privacy policy is a statement or a legal document (privacy law) that discloses some or all of the ways a party gathers, uses, discloses and manages a customer or client’s data.

Why Privacy Policy ?

Privacy policy is a way to protect the application users data so that it wont be stolen or misused by the application developer.

One of the Windows 8 Application Certification Requirements is to add a privacy policy to your application.

How to add a privacy policy ?

Now I’ll show you how to add a privacy policy to your application and an about page using the settings charm.

Firstly write your privacy policy and upload it online so that you an add it (recommended) or you can use a generic privacy policy 
http://www.freeprivacypolicy.org/generic.php

Second after finishing your project right click your project in the solution explorer and choose Add > New item

then choose user control and rename it to “About.xaml”

Image

then in the XAML page created copy and paste the following code in the grid tag

<Grid>

<StackPanel>

<TextBlock Text=”App Name” FontFamily=”Segoe UI” FontWeight=”SemiLight” FontSize=”26.667″ /> <TextBlock Text=”Version-1.0.0.0″ FontFamily=”Segoe UI” FontWeight=”SemiLight” FontSize=”18″ />

</StackPanel>

</Grid>

replace the “App Name” with the name of your application later on

now we’ll need to add the function that will display the user control we created when we press the settings charm so we’ll just edit the App.xaml.cs file

as a prerequisite you need to install Callisto which is a library that has a set of controls that will help you in your development you’ll find it here 

http://visualstudiogallery.msdn.microsoft.com/0526563b-7a48-4b17-a087-a35cea701052

after installing it just right click the References in the Solution explorer and choose add a reference then in the search type Callisto then add it

Image

now go to App.xaml.cs and add the following namespaces in the beginning of the file

 using Windows.UI.ApplicationSettings;

using Callisto.Controls;

using Windows.UI;

using Windows.UI.Popups;

 using Windows.System;

Image

Now , Add the following field to the App class.

private Color _background = Color.FromArgb(255, 0, 77, 96);

Image

Now, Add the following statements to the OnLaunched method

SettingsPane.GetForCurrentView().CommandsRequested += OnCommandsRequested;

Now, Add the following event handler to App.xaml.cs

void OnCommandsRequested(SettingsPane sender, SettingsPaneCommandsRequestedEventArgs args) { // Add an About command   var about = new SettingsCommand(“about”, “About”, (handler) =>   {      var settings = new SettingsFlyout();      settings.Content = new About();    settings.HeaderBrush = new SolidColorBrush(_background);      settings.Background = new SolidColorBrush(_background);      settings.HeaderText = “About”;      settings.IsOpen = true; });  args.Request.ApplicationCommands.Add(about); // Adding a Privacy Policy var privacy = new SettingsCommand(“privacypolicy”, “Privacy Policy”, OpenPrivacyPolicy); args.Request.ApplicationCommands.Add(privacy); }

Now add the OpenPrivacyPolicy method:

private async void OpenPrivacyPolicy(IUICommand command) {    Uri uri = new Uri(“http://Add A Link for your Privacy policy”);    await Launcher.LaunchUriAsync(uri); }

Image

now when you open the application press the settings charm and you’ll find the 2 options added Privacy Policy and About

Image

Image