I am using swipeview
feature on my project for swiping the flowlistviews
. I need both the left and right swipe for my center flowlistview. How can I achieve this on swipeview
?
My code:
<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
}
I need to call different functions based on the SwipeDirection
value(left or right).
Also, I tried SwipeGestureRecognizer
but it is not working for flowlistview.
You would better add SwipeGestureRecognizer
on the DataTemplate
instead of the whole FlowListView(otherwise it will be conflict with the default scroll event of 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>
Since you handle the logic in Code Behind without using MVVM . You should use swipe event instead of command .
<StackLayout.GestureRecognizers>
<SwipeGestureRecognizer Direction="Left" Swiped="SwipeGestureRecognizer_Swiped"/>
</StackLayout.GestureRecognizers>
private void SwipeGestureRecognizer_Swiped(object sender, SwipedEventArgs e)
{
// set List2 ...
}
In addition, in your case the best solution is to use Tabbed Page . Which will support such a function in default .