Search code examples
xamarin.formsuwpcustom-renderer

Xamarin forms: Entire row highlighting when tapped FlowListView item?


I have added FlowListView in my project. As mention in the FAQ I am facing the entire row highlighting issue when tapped one item in windows, no such issue in android. I have added the custom renderers like below:

In Main Project:

using DLToolkit.Forms.Controls;

namespace Mynamespace
{
    public class CustomFlowListView : FlowListView
    {
    }
}

In 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;
        }
    }
}

In xaml added <local:CustomFlowListView> instead of <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>

Are there any other changes instead of this for solving this issue?


Solution

  • How can I disable entire row highlighting when tapped?

    You also need to add List.IsItemClickEnabled = false. And it will not effect FlowItemTapped event. protected override void

    OnElementChanged(ElementChangedEventArgs<Xamarin.Forms.ListView> e)
    {
        base.OnElementChanged(e);
    
        if (List != null)
            List.SelectionMode = Windows.UI.Xaml.Controls.ListViewSelectionMode.None;
            List.IsItemClickEnabled = false;
    }