Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>you can consider something like that:</p> <ol> <li><p>define a style for textblock, or any other control you want to use to display your enum:</p> <pre><code> &lt;Style x:Key="enumStyle" TargetType="{x:Type TextBlock}"&gt; &lt;Setter Property="Text" Value="&amp;lt;NULL&amp;gt;"/&gt; &lt;Style.Triggers&gt; &lt;Trigger Property="Tag"&gt; &lt;Trigger.Value&gt; &lt;proj:YourEnum&gt;Value1&lt;proj:YourEnum&gt; &lt;/Trigger.Value&gt; &lt;Setter Property="Text" Value="{DynamicResource yourFriendlyValue1}"/&gt; &lt;/Trigger&gt; &lt;!-- add more triggers here to reflect your enum --&gt; &lt;/Style.Triggers&gt; &lt;/Style&gt; </code></pre></li> <li><p>define your style for ComboBoxItem</p> <pre><code> &lt;Style TargetType="{x:Type ComboBoxItem}"&gt; &lt;Setter Property="ContentTemplate"&gt; &lt;Setter.Value&gt; &lt;DataTemplate&gt; &lt;TextBlock Tag="{Binding}" Style="{StaticResource enumStyle}"/&gt; &lt;/DataTemplate&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;/Style&gt; </code></pre></li> <li><p>add a combobox and load it with your enum values:</p> <pre><code> &lt;ComboBox SelectedValue="{Binding Path=your property goes here}" SelectedValuePath="Content"&gt; &lt;ComboBox.Items&gt; &lt;ComboBoxItem&gt; &lt;proj:YourEnum&gt;Value1&lt;/proj:YourEnum&gt; &lt;/ComboBoxItem&gt; &lt;/ComboBox.Items&gt; &lt;/ComboBox&gt; </code></pre></li> </ol> <p>if your enum is large, you can of course do the same in code, sparing a lot of typing. i like that approach, since it makes localization easy - you define all the templates once, and then, you only update your string resource files.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload