title: Using enum value in XAML
body: <p>I have defined an enum in C#</p>
  <pre><code>public enum PointerStyle
  {
    Pointer,
    Block,
    Slider
  } ;
  </code></pre>
  <p>I am using it as a dependency property on a WPF custom control</p>
  <pre><code>public static DependencyProperty DisplayStyleProperty =
      DependencyProperty.Register(&quot;DisplayStyle&quot;, typeof(PointerStyle), typeof(Pointer), new PropertyMetadata(PointerStyle.Pointer));
  
  public PointerStyle DisplayStyle
  {
    get { return (PointerStyle)GetValue(DisplayStyleProperty); }
    set { SetValue(DisplayStyleProperty, value); }
  }
  </code></pre>
  <p>and using it in a ControlTemplate</p>
  <pre><code>&lt;Trigger Property=&quot;DisplayStyle&quot; Value=&quot;{x:Static local:PointerStyle.Block}&quot;&gt;
  </code></pre>
  <p>Very often, but not always, the editor underlines most of the code and shows the error &quot;'Block' is not a valid value for property 'DisplayStype'.&quot; as shown in the following screen shot</p>
  <p><a href="https://i.stack.imgur.com/A1S9G.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/A1S9G.png" alt="enter image description here" /></a></p>
  <p>This is in Visual Studio 2015.</p>
  <p>At runtime, the code works perfectly.<br />
  In the design window of my test program, the control is rendered totally incorrectly.</p>
  <p>What am I doing wrong?<br />
  What is the best way to refer to an enum value in XAML?</p>
  <p>(I would be happy to use a TypeConverter and to define the value as a string, but I can't find a good example of how do it.)</p>