i'm developing a Windows Phone 8 app on Xamarin Forms in C#.
I need to open the store following a click on an DisplayAlert.
if (condition)
{
await DisplayAlert(title,body,button);
//link to store for upgrading the app version
}
but i'm stuck in this, i cannot do an "on click listener" of the button inside the displayalert and i don't know how to link to the store outside it (in a brutal and less elegant way)
but i'm stuck in this, i cannot do an "on click listener" of the button inside the displayalert and i don't know how to link to the store outside it (in a brutal and less elegant way)
For your requirement, you could gracefully realize it via dependence service.
public interface OpenStore
{
Task<bool> OpenStore();
}
implement OpenStore
interface in your client project.
[assembly:Dependency(typeof(IOpenStore))]
public class IOpenStore : OpenStore
{
public async Task<bool> OpenStore()
{
var storeUri = new Uri("ms-windows-store://home");
var success = await Windows.System.Launcher.LaunchUriAsync(storeUri);
return success;
}
}
Usage
var answer = await DisplayAlert("Question?", "Would you like to open store", "Yes", "No");
if (answer)
{
await DependencyService.Get<OpenStore>().OpenStore();
}
Your app can use the ms-windows-store: URI scheme to Launch the Windows Store app. Open product detail pages, product review pages, and search pages, etc. For example, the following URI opens the Windows Store app and launches the home page of the Store.
ms-windows-store://home/
For more info, see Launch the Windows Store app.