Forum Xamarin.Forms

How to create SnackBar in Xamarin Forms Shell layout?

Dinesh_OfficialDinesh_Official Member ✭✭✭
edited February 10 in Xamarin.Forms

Hello Everyone,

I am trying to create a SnackBar to indicate whether the device is in offline or online mode. I have loaded all my views in a Shell layout and looking to show SnackBar which i could n't. If it is other than Shell layout, i'll use AbsoluteLayout or Grid to show my SnackBar at the bottom of the View.

Note: Somehow, i tried to load my SnackBar in each ShellContent and it gets worked. But i need to know is there any actual solution for this?

Any advice please :)

Answers

  • jezhjezh Member, Xamarin Team Xamurai

    Do you want a common SnackBar for all ShellContents? Then where would you like to put it?

  • Dinesh_OfficialDinesh_Official Member ✭✭✭
    edited February 11

    @jezh , yes exactly. Just above the tab bar.

  • jezhjezh Member, Xamarin Team Xamurai

    You can try to create a parent class BaseContentPage as follows, and define your SnackBar in this parent class.
    And other classes of the tab Page inherit from this parent class.

       public class BaseContentPage : ContentPage
        {
            // define your SnackBar  and initialize it
            public BaseContentPage(){
    
            }   
        }
    
Sign In or Register to comment.