Xamarin.forms Xamarin表单:点击FlowListView项时整行高亮显示?

Xamarin.forms Xamarin表单:点击FlowListView项时整行高亮显示?,xamarin.forms,uwp,custom-renderer,Xamarin.forms,Uwp,Custom Renderer,我在项目中添加了FlowListView。正如在中提到的,当在窗口中点击一个项目时,我面临整行突出显示问题,而在android中则没有此类问题。我添加了自定义渲染器,如下所示: 在主项目中: using DLToolkit.Forms.Controls; namespace Mynamespace { public class CustomFlowListView : FlowListView { } } using Listpm; using Listpm.UWP;

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

在主项目中:

using DLToolkit.Forms.Controls;

namespace Mynamespace
{
    public class CustomFlowListView : FlowListView
    {
    }
}
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;
        }
    }
}
在UWP中:

using DLToolkit.Forms.Controls;

namespace Mynamespace
{
    public class CustomFlowListView : FlowListView
    {
    }
}
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;
        }
    }
}
使用Listpm;
使用Listpm.UWP;
使用Xamarin.Forms;
使用Xamarin.Forms.Platform.UWP;
[程序集:ExportRenderer(typeof(CustomFlowListView)、typeof(CustomListViewRenderer))]
名称空间Listpm.UWP
{
类CustomListViewRenderer:ListViewRenderer
{
受保护的覆盖无效OnElementChanged(ElementChangedEventArgs e)
{
基础。一个要素发生变化(e);
如果(列表!=null)
List.SelectionMode=Windows.UI.Xaml.Controls.ListViewSelectionMode.None;
}
}
}
在xaml中添加了
而不是

<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>

为了解决这个问题,有没有其他的改变

点击时如何禁用整行高亮显示

您还需要添加
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;
}
OnElementChanged(ElementChangedEventArgs e)
{
基础。一个要素发生变化(e);
如果(列表!=null)
List.SelectionMode=Windows.UI.Xaml.Controls.ListViewSelectionMode.None;
List.IsItemClickEnabled=false;
}

List.SelectionMode=Windows.UI.Xaml.Controls.ListViewSelectionMode.None将禁用ListView行高亮显示。那么您想要什么行为?@NicoZhu MSFT但在添加上述渲染器后,单击一个项目时,我的listview整行将高亮显示。请尝试使用此行
List.SelectionMode=Windows.UI.Xaml.Controls.ListViewSelectionMode.Single
@NicoZhu MSFT不走运,单击一个项目时,整行将突出显示。请尝试在渲染
列表中添加该行。IsItemClickEnabled=false