简体   繁体   中英

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?

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.

What is the "FlowItemTappedCommand"?

Yes is probably just a command like tapped that can be bound to your itemVm

Is it TapGestureRecognizer instead of ItemSelected?

Im not sure what you mean here, but essentially yes when you tap the item it raises a command at your VM.

How should i implement this command

Like any other command really

How can i get now selected (tapped) item in ViewModel?

This is the problem with you using underdocumented nugets off the web, who knows?

However, Im just going to take a stab at this from looking at the source. Try

FlowLastTappedItem="{Binding LastTappedItem}"

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

In all honesty, the guy has a blog and is visible on SO, you should really point these comments at him, or his gitub page, or at least tag the control in the question

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM