Solved: WPF Toggle Combo Box Item Text Colour MVVM ReactiveUI


OK so this is definitely a newbie question that unfortunately could not figure/find the answer to.
Essentially binding a list of objects to a Combobox, when the Disabled property on the object is set to true I want the text colour of the Combobox item to be set to gray.
This is what I have so far:
Combobox item datatype
Viewmodel setup
ReactiveUI Binding
Xaml markup
Any help is appreciated let me know if you need more information.
Solution: It looks like in future I need to test the example code before puttin it up – our actual code had the Disabled property set as a readonly which must mess with WPF binding. Changing it to public set and get solved the first issue of not seeing it greyed out! It would seem staring at a problem for so long blinds you and it really is that simple. As for graying out the selected item I will try it out and see.

Best Answer:

The last item in the dropdown already has its text grayed out, so I assume you’re asking about the selected item. The ComboBox uses separate data templates for the selected item and the items in the dropdown. You can use a DataTemplateSelector to set both.
Xaml markup

We have some repetition in the DataTemplate definitions, but these tend to grow apart in production code.

If you have better answer, please add a comment about this, thank you!