当列表项是包装在内容视图中的轻扫视图时,列表视图的 ItemSelected 事件未触发



我已经用ListView完美地测试了SwipeView的功能。但是,当我将它封装在ContentView中时,滑动操作正在工作,但ListView的ItemSelected事件没有启动。

样本代码:

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="App2.MainPage">
<StackLayout>
<ListView x:Name="EmployeeView"
ItemSelected="EmployeeView_ItemSelected">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<ContentView>
<SwipeView>
<SwipeView.LeftItems>
<SwipeItems>
<SwipeItem Text="Favorite"
BackgroundColor="Blue"/>
<SwipeItem Text="Delete"
BackgroundColor="LightPink" />
</SwipeItems>
</SwipeView.LeftItems>
<StackLayout Orientation="Horizontal"
BackgroundColor="GreenYellow">
<Label Text="{Binding Name}"/>
<Label Text="{Binding Age}"/>
</StackLayout>
</SwipeView>
</ContentView>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
</ContentPage>

我使用的是XF 5.0.0.2012,仅在安卓系统上进行了测试。

在我的实际需求中,我使用的是分组ListView,其中大多数组不需要滑动操作。当列表项目数越来越大时,观察到滑动项目加载的一些滞后。因此,考虑仅在需要时使用SwipeView,否则使用只读网格。因此计划基于触发器设置ContentView。

ListView似乎有问题,但CollectionView也可以使用相同的场景。

最新更新