禁用ListView中的选择项目



对于我正在处理的社交网络应用程序,我正在尝试使用listView显示评论,但我不希望在单击时突出显示。

我尝试使用

`((ListView)sender).SelectedItem = null;` in a selected event but that still shows it being selected for a second. I need it to never show.

我还尝试将列表视图设置为

IsEnabled="False"

还尝试将其放在视图单元格中,但会导致按钮,然后单击事件不起作用。

android:

我为ListView创建了一个自定义渲染器,并设置

Control.SetSelector(Android.Resource.Color.Transparent);

ios:

我创建了一个自定义ViewCell渲染器并设置

cell.SelectionStyle = UITableViewCellSelectionStyle.None;

参考:

android:xamarin.forms untappable listView(删除选择连锁效果(

ios:https://montemagno.com/adding-a-disclusion-indicator-indicator-accessory-to/

您可以尝试这样的东西,

myListView.ItemTapped += (object sender, ItemTappedEventArgs e) => {    
   if (e.Item == null) return;     
    ((ListView)sender).SelectedItem = null; 
 }; 

最新更新