how to get the selectedItem inside Stackalyout in ListView ?

MrLovaMrLova USMember ✭✭

Hi Guys,

following senario,

I have a listview with ItemTemplate that is tied to a model, and within Listview I have several stack layouts (text, entrys, ..) and now if I am in an event of entry for example I would like to have my SelectedItem (Model) ,

how can i access the SelectedItem within the textchanged (entry), which in turn is in a listview?

How can I realize this?

thank you in advance


  • MabroukMabrouk USMember ✭✭✭
    edited November 2017


    you can do it like bellow using CommandParameter="{Binding}" :

    1. ListView :

                  ItemsSource="{Binding Items}" 
                  SeparatorVisibility="None" >
                              <Label Text="Click here!">
                                      <TapGestureRecognizer Tapped="TapGestureRecognizer_Tapped" CommandParameter="{Binding}"/>
    2. Your label Event :

      private void TapGestureRecognizer_Tapped(object sender, TappedEventArgs e)
                  var r = e.Parameter; //Here you will find your data (Model)

    I hope that helps,

  • MrLovaMrLova USMember ✭✭

    hallo Mabrouk,

    thanks a lot for the quick and simple solution.
    it seems to be going in the right direction.
    But I have to click on the label so that the event is resolved. However, i would resolve the event TapGestureRecognizer_Tapped on a entry unfocused event.

    it is possible to fire "TapGestureRecognizer_Tapped "event on entry ?

Sign In or Register to comment.