简体   繁体   English

根据WPF中GridView / ListView的相邻单元格的值进行过滤

[英]Filter based on value of adjacent cell of GridView/ListView in WPF

I have a ListView with a variable number of items in a WPF project with two columns. 我有一个带有两列的WPF项目中具有可变数量项的ListView。 Column A is a string, column B is a combobox. 列A是字符串,列B是组合框。 I have the ListView bound to some collectionView, and the combobox column is a cellTemplate, binding the combobox to some other collectionView or observableCollection. 我将ListView绑定到某些collectionView,并且combobox列是cellTemplate,将combobox绑定到其他collectionCollection或observableCollection。

Is there some way to filter the collection shown in the combobox in column B dynamically based on the value of column A? 有什么方法可以根据A列的值动态过滤B列组合框中显示的集合?

I am open to replacing the ListView with some other control if it would grant me the functionality described. 我愿意用其他控件替换ListView,如果它可以授予我所描述的功能。

Perhaps you could achieve this by binding the combobox property B's ItemsSource to 也许您可以通过将组合框属性B的ItemsSource绑定到

{Binding Path=PropertyA, Converter={StaticResource ItemsConverter}} 

Then write a IValueConverter which takes a TypeA and returns a IEnumerable. 然后编写一个IValueConverter,它接受TypeA并返回IEnumerable。 Whack that into the Resources so the StaticResource can find it. 将其打包到资源中,以便StaticResource可以找到它。

Bob's your uncle. 鲍勃是你的叔叔。

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

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