locked
How to create the popups like toast in xamarin forms. RRS feed

  • Question

  • User355323 posted

    Hi, I need to create the popups like toast to show the cart details for user, I've attached a sample image

    Thanks.

    Thursday, June 18, 2020 7:57 AM

Answers

  • User385619 posted

    You can use ACR Userdialogs for that https://github.com/aritchie/userdialogs

    Alternatively you can write a dependency service that displays the toast for the corresponding platform.

    Edit: Or perhaps what you are looking for is called a Snackbar https://doumer.me/creating-a-snack-bar-in-xamarin-forms-xaml/ There is also a plugin https://github.com/ice-j/Plugin.XSnack

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Thursday, June 18, 2020 8:22 AM
  • User379860 posted

    You could use DependenceService to achieve it as well.

    First of all, create a interface

    public interface Toast
    {
    void Show(string message);
    }

    In Xamarin.Android, you can achieve this interface like following method.

    ``` using Android.Widget; using ToastDemo.Droid;

    [assembly: Xamarin.Forms.Dependency(typeof(MyToastService))] namespace ToastDemo.Droid { public class MyToastService: Toast
    {
    public void Show(string message) { Android.Widget.Toast.MakeText(Android.App.Application.Context, message, ToastLength.Long).Show(); } } }

    ```

    For IOS or UWP achievement, you can Google: Xamarin.Forms - How To Make Toast Message Using Dependency Service

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Thursday, June 18, 2020 11:22 AM

All replies

  • User385619 posted

    You can use ACR Userdialogs for that https://github.com/aritchie/userdialogs

    Alternatively you can write a dependency service that displays the toast for the corresponding platform.

    Edit: Or perhaps what you are looking for is called a Snackbar https://doumer.me/creating-a-snack-bar-in-xamarin-forms-xaml/ There is also a plugin https://github.com/ice-j/Plugin.XSnack

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Thursday, June 18, 2020 8:22 AM
  • User355323 posted

    Thanks @Graverobber Exactly i am looking for, will try and mark your answer as accepted.

    Thursday, June 18, 2020 8:34 AM
  • User379860 posted

    You could use DependenceService to achieve it as well.

    First of all, create a interface

    public interface Toast
    {
    void Show(string message);
    }

    In Xamarin.Android, you can achieve this interface like following method.

    ``` using Android.Widget; using ToastDemo.Droid;

    [assembly: Xamarin.Forms.Dependency(typeof(MyToastService))] namespace ToastDemo.Droid { public class MyToastService: Toast
    {
    public void Show(string message) { Android.Widget.Toast.MakeText(Android.App.Application.Context, message, ToastLength.Long).Show(); } } }

    ```

    For IOS or UWP achievement, you can Google: Xamarin.Forms - How To Make Toast Message Using Dependency Service

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Thursday, June 18, 2020 11:22 AM
  • User355323 posted

    @LeonLu Thanks

    Thursday, June 18, 2020 2:54 PM