WPF - 如何清除ListView中的选择? [英] WPF - How to clear selection from ListView?

查看:593
本文介绍了WPF - 如何清除ListView中的选择?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这看来似乎应该是相当简单的,但我似乎无法得到它的工作。

This seems like it should be something fairly simple, but I just can't seem to get it to work.

我想以编程方式清除当前所选项目的选择在我的ListView。

I'd like to programatically clear the selection of the currently selected item in my ListView.

我试过设置的SelectedValue为空,设置的SelectedItem为空,并将selectedIndex设置为-1,甚至试图调用UnselectAll方法。在每一个案例,SelectedItems.Count还是等于一...

I've tried setting SelectedValue to null, setting SelectedItem to null, setting the SelectedIndex to -1, and even tried calling the UnselectAll method. In each and every case, SelectedItems.Count is still equal to one...

任何想法?

推荐答案

您必须把它放到一个空的集合

You must put it into an empty collection

ListView.UnselectAll();

我再次阅读问题。如果它不工作,那么问题可能是具有约束力。是的ListView 绑定??

这篇关于WPF - 如何清除ListView中的选择?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆