简体   繁体   中英

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. Column A is a string, column B is a combobox. I have the ListView bound to some collectionView, and the combobox column is a cellTemplate, binding the combobox to some other collectionView or observableCollection.

Is there some way to filter the collection shown in the combobox in column B dynamically based on the value of column A?

I am open to replacing the ListView with some other control if it would grant me the functionality described.

Perhaps you could achieve this by binding the combobox property B's ItemsSource to

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

Then write a IValueConverter which takes a TypeA and returns a IEnumerable. Whack that into the Resources so the StaticResource can find it.

Bob's your uncle.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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