WPF - 如何清除ListView中的选择?WPF、ListView

2023-09-03 20:40:44 作者:帅比点这好吗。

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

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 绑定??