Question

I have a ListBox in which I store LogEvents. The LogEvent class contains a String property named "Event". I need to apply a specific style based on the content of that property. However, the condition is not based on a static value, but on a condition like Event.Contains("blabla").

I think the simplest way to do this is to use DataTriggers on the style to apply and a ValueConverter in which I would apply the condition and convert the result to a static value for the "Value" property of the DataTrigger. Is there a more elegant way to do this without using a Converter, which I don't particularly like?

Was it helpful?

Solution

perhaps a more elegant solution would be to create a DataTemplateSelector and you wire it in to your listbox like so - ItemTemplateSelector="{StaticResource MyTemplateSelector}"

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top