Search code examples
firebase-realtime-databasexamarin.formsswipe

Save swipe item to firebase realtime in xamarin form


I want to save the swipe selected to firebase. but idk how to do it and cant find any solution to internet.

This is my codes in swipe view

<SwipeView x:Name="swipe_orderstatus">

                                    <SwipeView.RightItems >
                                        <SwipeItems >
                                            <SwipeItem Text="Received"
                                                       BackgroundColor="#73a9c2"
                                                     
                                                       
                                                      Invoked="SwipeItem_Invoked_1"
                                                />
                                            
                                        </SwipeItems>
                                    </SwipeView.RightItems>

</SwipeView>

then this is what I've tried in code behind.

  private void SwipeItem_Invoked_1(object sender, EventArgs e)
        {
            //  string swipeIt
            //  string swipeViewItem= swipe var picker = (Picker)sender;
            //    int selectedIndex = picker.SelectedIndex;
            var swipeView = (SwipeView)sender;
            string swipeViewItem= swipeView
        }

thank you in advance.


Solution

  • you can get the selected item using the BindingContext

    var swipeView = (SwipeView)sender;
    var item = (MyClass)swipeView.BindingContext;
    

    where MyClass is the name of the class representing your model