App Bar, Rate and Share

In this blog post, you will learn the following:wp_ss_20150316_0001

  • Add App Bar (XAML)
  • Add Rate and Review Button in your App
  • Add more apps Button “related to you on the store”
  • Add App details Button
  • Add Share Button

Let’s get started 😉

Add App Bar (XAML)

  1. Open Visual Studio, Create new project (Windows Phone 8.1 > Blank Template).
  2. In Solution Explorer, Open MainPage.xaml and Add this code outside the main Grid:
    AppBar

Now, you have been created an App Bar but, we need to handle these AppBarButtons 😀

Add Rate and Review Button

In Solution Explorer, Open MainPage.xaml.cs and Add this code in RateBtn_Click event handler:

await Launcher.LaunchUriAsync
 (new Uri("ms-windows-store:reviewapp?appid=" + Windows.ApplicationModel.Store.CurrentApp.AppId));

Add More Apps Button

This button navigates to related apps in the store, maybe other apps for you in the store or any related apps to you using a keyword in store search bar.

Add this code in moreAppsBtn_Click event handler:

string keyword = "Mohammed Emam";
var uri = new Uri(string.Format(@"ms-windows-store:search?keyword={0}", keyword));
await Windows.System.Launcher.LaunchUriAsync(uri);

Add App Details Button

This button navigates to your app details page on the store.

Add this code in detailsBtn_Click event handler:

var uri = new Uri(string.Format("ms-windows-store:navigate?appid={0}", Windows.ApplicationModel.Store.CurrentApp.LinkUri));
await Windows.System.Launcher.LaunchUriAsync(uri);

Add Share Button

This button will share your app’s link.

Add this Method in MainPage.xaml.cs



private void RegisterForShare()
 {
     DataTransferManager dataTransferManager = DataTransferManager.GetForCurrentView();
     dataTransferManager.DataRequested += new TypedEventHandler<DataTransferManager,
     DataRequestedEventArgs>(this.ShareLinkHandler);
 }

private void ShareLinkHandler(DataTransferManager sender, DataRequestedEventArgs e)
 {
     DataRequest request = e.Request;
     request.Data.Properties.Title = "Title";
     request.Data.Properties.Description = "Description";
     request.Data.SetWebLink(new Uri(""+ Windows.ApplicationModel.Store.CurrentApp.LinkUri));
 }


Then, call this method in shareBtn_Click event handler and add this line of code:

RegisterForShare(); //Calling the method
 DataTransferManager.ShowShareUI();

 

Download the entire code sample from HERE

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s