简体   繁体   English

Xamarin.Forms如何禁用列表视图上的悬停突出显示效果

[英]Xamarin.Forms How can I disable hover highlight effect on listview

I am developing a Xamarin.Forms project that uses a Listview. 我正在开发一个使用Listview的Xamarin.Forms项目。

In this listview, I use a datatemplate to show my own made cards in the listview. 在此列表视图中,我使用数据模板在列表视图中显示自己制作的卡片。 The listview with my custom made cards renders correctly, however there is one thing that doesn't go as expected. 使用我的定制卡片制作的listview可以正确呈现,但是有一件事没有按预期进行。

In the UWP application, when I hover over an item in the listview, a hover highlight colour appears on my card. 在UWP应用程序中,当我将鼠标悬停在列表视图中的某个项目上时,我的卡上将出现一个悬停突出显示颜色。 I want to disable the hover effect completely for all listviews in the app. 我想完全禁用该应用程序中所有列表视图 的悬停效果

I know this is standard behaviour in a UWP application but I like to disabled it completely. 我知道这是UWP应用程序中的标准行为,但我想完全禁用它。

I already tried to make a control template in App.xaml, but I can't get it working. 我已经尝试在App.xaml中制作一个控件模板,但无法使其正常工作。 I already tought to make a custom renderer but I don't know how I can do this. 我已经很努力地制作一个自定义渲染器,但是我不知道该怎么做。

I also use a custom control (FlowListView by DLToolkit) which also uses a hover effect just like listview. 我还使用了一个自定义控件(DLToolkit的FlowListView),它也像列表视图一样使用了悬停效果。

How can I disable the hover highlight colour effect in a listview/FlowListView using Xamarin.Forms? 如何使用Xamarin.Forms在listview / FlowListView中禁用悬停突出显示颜色效果?

I don't know if it works. 我不知道是否行得通。 But have you tried disabling itemSelection: 但是您是否尝试禁用itemSelection:

MyListView.ItemSelected += (sender, e) => {
     ((ListView)sender).SelectedItem = null;
};

I fixed this problem by setting FlowTappedBackgroundColor and FlowRowBackgroundColor to a same colour. 我通过将FlowTappedBackgroundColorFlowRowBackgroundColor设置为相同的颜色来解决此问题。

Note that the highlight colour is still there, however you can't notice because the highlight colour is the same as the background colour. 请注意 ,突出显示颜色仍然存在,但是您不会注意到,因为突出显示颜色与背景颜色相同。

lstFlowList.FlowTappedBackgroundColor = Color.White;
lstFlowList.FlowRowBackgroundColor = Color.White;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM