문제

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?

도움이 되었습니까?

해결책

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top