Xamarin.forms Xamarin表单:如何从SwipeStarted事件获取SwipeDirection值?

Xamarin.forms Xamarin表单:如何从SwipeStarted事件获取SwipeDirection值?,xamarin.forms,swipeview,Xamarin.forms,Swipeview,我正在项目中使用swipeview功能来滑动FlowListView。我需要同时向左和向右滑动我的中心flowlistview。如何在swipeview上实现这一点 我的代码: <SwipeView x:Name="SwipeView2" SwipeStarted="CenterSwipeView" IsVisible="False"> <SwipeView.RightItems> <SwipeItems>

我正在项目中使用swipeview功能来滑动FlowListView。我需要同时向左和向右滑动我的中心flowlistview。如何在swipeview上实现这一点

我的代码:

<SwipeView
    x:Name="SwipeView2"
    SwipeStarted="CenterSwipeView"
    IsVisible="False">
    <SwipeView.RightItems>
        <SwipeItems>
            <SwipeItem/>
        </SwipeItems>
    </SwipeView.RightItems>
    <flv:FlowListView>
        //listview items
    </flv:FlowListView>
</SwipeView>

public void CenterSwipeView(object sender, SwipeStartedEventArgs args)
{
  //how can I get the SwipeDirection value here
}
我需要根据SwipDirection值Left或right调用不同的函数

另外,我尝试了SwipeGestureRecognizer,但它对flowlistview不起作用

您最好在DataTemplate上而不是整个FlowListView上添加SwipeGestureRecognizer,否则它将与listview的默认滚动事件冲突

<DataTemplate>
    <StackLayout BackgroundColor="LightBlue" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand">

        <StackLayout.GestureRecognizers>
            <SwipeGestureRecognizer Direction="Left" Command="{Binding xxx}"/>
            <SwipeGestureRecognizer Direction="Right" Command="{Binding xxx}"/>
        </StackLayout.GestureRecognizers>

        // the elements


    </StackLayout>  
</DataTemplate>

此外,在您的情况下,最好的解决方案是使用选项卡式页面。默认情况下,它将支持此功能。

我尝试过此功能,但不起作用。我已经制作了一个样品,你能看一下吗。当前,当点击页面顶部的标签时,flowlistview会在UI上逐个显示。我这里也需要滑动FlowListView。我使用了滑动事件,但滑动时事件不会触发。我正在为所有平台开发,不仅仅是android平台。ios的标签在底部,所以我不能在这里这么做。你可以使用插件
<StackLayout.GestureRecognizers>
    <SwipeGestureRecognizer Direction="Left" Swiped="SwipeGestureRecognizer_Swiped"/>
</StackLayout.GestureRecognizers>
private void SwipeGestureRecognizer_Swiped(object sender, SwipedEventArgs e)
{
   // set List2 ...
}