Search code examples
c#xamllistviewxamarinselecteditem

Xamarin.Forms DLToolkit FlowListView How to get selected item?


In my project I have to work with this plug-in: https://github.com/daniel-luberda/DLToolkit.Forms.Controls/tree/master/FlowListView/DLToolkit.Forms.Controls.FlowListView

Here is the part of my XAML:

    <flv:FlowListView 
        IsGroupingEnabled="true"
        FlowGroupDisplayBinding="{Binding Path=Letter}"
        FlowColumnCount="2" 
        FlowItemsSource="{Binding CitiesAlphabet}"
        FlowItemTappedCommand="{Binding TapCity, Mode=TwoWay}"
        x:Name="CityList"
    >

What is the "FlowItemTappedCommand"? Is it TapGestureRecognizer instead of ItemSelected? How should I implement this command, and how can I get now selected (tapped) item in ViewModel?

Is there any detailed manual with examples how to work with this plug-in?


Solution

  • FlowItemTappedCommand="{Binding CityTappedCommand}"
    

    Implementation of the command:

    public ICommand CityTappedCommand{ get; set; }
    

    You can initialize it in the constructor of the viewmodel

    CityTappedCommand = new Command(() => YourSub());
    

    To get the selected item, you can add the following in your xaml:

    FlowLastTappedItem = "{Binding SelectedCity}"
    

    and then get SelectedCity in you viewmodel.