简体   繁体   English

Xamarin.Forms DLToolkit FlowListView如何获取所选项目?

[英]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 在我的项目中,我必须使用此插件: https : //github.com/daniel-luberda/DLToolkit.Forms.Controls/tree/master/FlowListView/DLToolkit.Forms.Controls.FlowListView

Here is the part of my XAML: 这是我的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 "? 什么是“ FlowItemTappedCommand ”? Is it TapGestureRecognizer instead of ItemSelected ? TapGestureRecognizer而不是ItemSelected吗? How should i implement this command and How can i get now selected (tapped) item in ViewModel? 我应该如何实现此命令,如何在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 您可以在viewmodel的构造函数中对其进行初始化

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

To get the selected item, you can add the following in your xaml: 要获取所选项目,可以在xaml中添加以下内容:

FlowLastTappedItem = "{Binding SelectedCity}"

and then get SelectedCity in you viewmodel. 然后在视图模型中获取SelectedCity。

What is the "FlowItemTappedCommand"? 什么是“ FlowItemTappedCommand”?

Yes is probably just a command like tapped that can be bound to your itemVm 是的,可能只是可以将其绑定到您的itemVm的类似tapped的命令

Is it TapGestureRecognizer instead of ItemSelected? 是TapGestureRecognizer而不是ItemSelected吗?

Im not sure what you mean here, but essentially yes when you tap the item it raises a command at your VM. 我不确定您的意思是什么,但是基本上是,当您点击该项目时,它会在您的VM上引发一个命令。

How should i implement this command 我应该如何执行此命令

Like any other command really 像其他命令一样

How can i get now selected (tapped) item in ViewModel? 现在如何在ViewModel中选择(点击)项目?

This is the problem with you using underdocumented nugets off the web, who knows? 这是您在网络上使用文档不足的nuget的问题,谁知道呢?

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 老实说,这个人有一个博客并且可以在SO上看到,您应该将这些评论指向他或他的gitub页面,或者至少在问题中标记控件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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