I have a simple .Net enum. I also have a view model object which has a ‘CurrentValue’ property of the type of my enum. This property can be data-bound (the object implements INotifyPropertyChanged). Now I’d like to show one UI element for each value of the enum, in a specific order, and have the ‘CurrentValue’ highlighted (bold). I would like the declaration to be something like:
<StackPanel Orientation='Vertical'> <ContentControl Content='{x:Static MyEnum.Value1}' /> <ContentControl Content='{x:Static MyEnum.Value2}' Margin='10' /> <ContentControl Content='{x:Static MyEnum.Value3}' /> </StackPanel>
I’d like to declare each value individually, to specify the order, but also because I want some of the elements to have specific margin values. Also, I will want to display specific icons for each value later on.
Now I’m lost as to how I can declare that I want the control associated with the CurrentValue to be bold. I tried using a generic DataTrigger inside a template to check the content against the CurrentValue, but it seems the Value of a trigger cannot be a binding.
I also considered going for a disabled ListBox, but then I can’t have specific margins for specific items. Or can I?
Try this on for size…
You’ll need to map the
localxmlns to your CLR namespace.