Johan
Johan

Reputation: 512

WPF searchable combobox with ItemTemplate

I have a ComboBox with Itemssource binding to a ListViewCollection on the VM. The ListViewCollection filters an ObservableCollection<ItemVM>

ItemVM has a property DisplayText which will be shown in the combobox.

The ComboBox Text is bound to a SearchString property on the VM of type string which is used for the ListCollectionView's filter.

I want my ItemVM to be templated so some items are displayed in red text based on propertyvalues on ItemVM.

The problem I have is that I cannot use DisplayPathName and itemstemplate at the same time.

Itemstemplate handles type ItemVM but the searchstring is string. This causes the text to sometime be the classname instead of the actual value.

If I would use strings instead of ItemVM it would work (but then I would have no properties to trigger color change from). What is the solution to make a searchable (filtered dropdown) combobox when the items are not of type string?

Upvotes: 0

Views: 546

Answers (0)

Related Questions