我正在尝试Xamarin Forms4.4中的新SwipeView控件,并且一直在使用FavFighters示例(Code on Github),我认为它非常棒。
我可以根据需要添加向右/向左滑动手势,但我无法找到如何将OnClick事件添加到主/详细类型项目的列表中。我希望使用向左/向右滑动操作作为快捷键,但希望用户单击列出的项目以进一步深入。
有没有办法将OnClick (或onSelected)事件添加到SwipeView项中?
发布于 2020-02-03 20:59:17
是的,你绝对可以使用Xamarin.Forms.Effects,它允许你用原生特性实现不同的效果。你可以参考这个:https://github.com/mrxten/XamEffects它展示了如何有轻击效果,长轻击效果,这将对你的情况很有帮助,即使没有安装第三方插件也可以做到。
发布于 2020-02-04 14:54:54
你想达到类似于GIF的效果吗?

如果要为SwipeView添加单击事件。只需像下面的代码一样在swipeView中添加GestureRecognizers即可。
<SwipeView>
<SwipeView.GestureRecognizers>
<TapGestureRecognizer Tapped="TapGestureRecognizer_Tapped"/>
</SwipeView.GestureRecognizers>
<SwipeView.LeftItems>
<SwipeItems>
<SwipeItem Text="Favorite"
BackgroundColor="LightGreen"
Invoked="SwipeItem_Invoked" />
<SwipeItem Text="Delete"
BackgroundColor="LightPink"
Invoked="SwipeItem_Invoked_1" />
</SwipeItems>
</SwipeView.LeftItems>
<!-- Content -->
<Grid HeightRequest="60"
WidthRequest="300"
BackgroundColor="LightGray">
<Label Text="Swipe right"
HorizontalOptions="Center"
VerticalOptions="Center" />
</Grid>
</SwipeView>在后台代码中。
private void TapGestureRecognizer_Tapped(object sender, EventArgs e)
{
Navigation.PushModalAsync(new Page1());
}https://stackoverflow.com/questions/60038979
复制相似问题