Xamarin 表单:点击 FlowListView 项目时整行突出显示?

Xamarin forms: Entire row highlighting when tapped FlowListView item?

我在我的项目中添加了 FlowListView。正如 FAQ 中提到的,当我在 windows 中点击一个项目时,我面临整行突出显示的问题,而在 android 中没有这样的问题。我添加了如下自定义渲染器:

在主项目中:

using DLToolkit.Forms.Controls;

namespace Mynamespace
{
    public class CustomFlowListView : FlowListView
    {
    }
}

在 UWP 中:

using Listpm;
using Listpm.UWP;
using Xamarin.Forms;
using Xamarin.Forms.Platform.UWP;

[assembly: ExportRenderer(typeof(CustomFlowListView), typeof(CustomListViewRenderer))]

namespace Listpm.UWP
{
    class CustomListViewRenderer : ListViewRenderer
    {
        protected override void OnElementChanged(ElementChangedEventArgs<ListView> e)
        {
            base.OnElementChanged(e);

            if (List != null)
                List.SelectionMode = Windows.UI.Xaml.Controls.ListViewSelectionMode.None;
        }
    }
}

在 xaml 中添加了 <local:CustomFlowListView> 而不是 <flv:FlowListView>

<local:CustomFlowListView
     FlowColumnCount="2" 
     SeparatorVisibility="None" 
     HasUnevenRows="false"
     RowHeight="200"
     FlowItemsSource="{Binding AllItems}">
     <flv:FlowListView.FlowColumnTemplate>
       <DataTemplate>
          <StackLayout
             HorizontalOptions="FillAndExpand"
             VerticalOptions="FillAndExpand"> 
              <Image/>
             </StackLayout>
        </DataTemplate>
     </flv:FlowListView.FlowColumnTemplate>
  </local:CustomFlowListView>

是否有其他更改来解决此问题?

How can I disable entire row highlighting when tapped?

您还需要添加 List.IsItemClickEnabled = false。它不会影响 FlowItemTapped 事件。 受保护的覆盖无效

OnElementChanged(ElementChangedEventArgs<Xamarin.Forms.ListView> e)
{
    base.OnElementChanged(e);

    if (List != null)
        List.SelectionMode = Windows.UI.Xaml.Controls.ListViewSelectionMode.None;
        List.IsItemClickEnabled = false;
}