Vort3x
Vort3x

Reputation: 1828

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.

Upvotes: 0

Views: 258

Answers (1)

Aron
Aron

Reputation: 15772

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.

Upvotes: 1

Related Questions