private void Application_Launching(object sender, LaunchingEventArgs e)
{
IsolatedStorageSettings.ApplicationSettings["askforreview"] = false;
int started = 0;
if (IsolatedStorageSettings.ApplicationSettings.Contains("started"))
{
started = (int)IsolatedStorageSettings.ApplicationSettings["started"];
}
started++;
IsolatedStorageSettings.ApplicationSettings["started"] = started;
if (started == 5)
{
IsolatedStorageSettings.ApplicationSettings["askforreview"] = true;
}
}
Place the following code in your MainPage.xaml.cs (or any other page which might be the startpage of your app, for example when your app is pinned another page might be the startpage)
protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
var askforReview = (bool)IsolatedStorageSettings.ApplicationSettings["askforreview"];
if (askforReview)
{
//make sure we only ask once!
IsolatedStorageSettings.ApplicationSettings["askforreview"] =false;
var returnvalue = MessageBox.Show("Thank you for using Rubber Duck for a while now, would you like to review this app?", "Please review my app", MessageBoxButton.OKCancel);
if (returnvalue == MessageBoxResult.OK)
{
var marketplaceReviewTask = new MarketplaceReviewTask();
marketplaceReviewTask.Show();
}
}
}