Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 91519

How to convert AlertDialog to Snackbar?

$
0
0

I have the following in my Xamarin.Forms project:

`if (ShouldShowRequestPermissionRationale(permission))
{
AlertDialog.Builder alert = new AlertDialog.Builder(this);
alert.SetTitle("Location permission needed");
alert.SetPositiveButton("Allow", (senderAlert, args) =>
{
RequestPermissions(PermissionsGroupLocation, RequestLocationId);
});

            alert.SetNegativeButton("Cancel", (senderAlert, args) =>
            {
                Toast.MakeText(this, "Cancelled", ToastLength.Short).Show();
            });

            Dialog dialog = alert.Create();
            dialog.Show();


            return;
        }`

I'd like to make it into a snackbar so it doesn't block the main page and dismisses itself after a few seconds

The main problem is that Snackbar.Make() takes a view as its first parameter but I'm using Xamarin Forms


Viewing all articles
Browse latest Browse all 91519

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>