如何在 Windows Phone 8.1 中以编程方式取消选择列表视图中的项目(绑定到列表 <myObject>)

How to deselect items in listview (bound to List<myObject>) programmatically in Windows Phone 8.1

Windows Phone 8.1 通用。

我需要能够 select 和 deselect 列表视图中的项目。 我无法以编程方式 select/deselect 单个项目,但我可以使用此方法 select listView 中的所有项目:

listView.SelectAll();

期望 deselect all 内置完全相反的方法是有道理的,但是 none.

我不能使用下面的代码,因为它没有绑定到 ListItem 对象列表,而是绑定到自定义对象

        foreach (var item in listView.SelectedItems)
        {
            //item.IsSelected isn't available because it's a custom object
        }

如何删除select列表视图中的所有项目?

如果想通了。以下代码取消选择 listView 中的所有项目:

listView.SelectedItems.Clear();

另一种方式是listiew.SelectedIndex = -1;