title: Enum DependencyProperty passed as Int from Setter
body: <p>I encountered this strange behavior, I have a UserControl with a CommandPosition DependencyProperty that accept an enum called "Position" declared inside the class* as:</p>
  
  <pre><code>public enum Position
  {
      Left,
      Right,
      Both
  }
  </code></pre>
  
  <p>*Inside or outside it's irrelevant in this situation, I tried both.</p>
  
  <p>The control moves some button around based on the defined Position.
  This is the property declaration, seems fine with me:</p>
  
  <pre><code>public static readonly DependencyProperty CommandPositionProperty = DependencyProperty.RegisterAttached("CommandPosition", typeof(Position), typeof(PoisonControl), new PropertyMetadata(Position.Right, OnPositionChanged));
  
  private static void OnPositionChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
  {
      if (e.NewValue is Position)
          ((PoisonControl)d).CommandPosition = (Position)e.NewValue;
  }
  </code></pre>
  
  <p>Inside the View, I correctly define my control and can set CommandPosition="Left" (and get Intellisense) without any problem, the OnPositionChanged method is called and a Position is passed to e.NewValue as expected.</p>
  
  <p>Now I need to change the position based on ViewState size, inside the ViewState.Setters I have this line:</p>
  
  <pre><code>&lt;Setter Target="Poison.CommandPosition" Value="Both" /&gt;
  </code></pre>
  
  <p>It kinda works, OnPositionChanged method is called, but the type of e.NewValue is System.Int32 (in this case 2) while e.OldValue is still Position (in this case 0).</p>
  
  <p>Why? Am I doing something wrong?
  I could make it work by casting the underlying type to Position, but I'd prefer not to and understand this strange behavior.</p>