title: Why does setting a default value on an enum dependency property fail in WinRT?
body: <p>I'm trying to use an enum as the type of a dependency property, but any setting of the default seems to fail.</p>
  
  <p>The compilation succeeds, but when I try to use the object in XAML I get a "Specified Cast is not Valid" error and the blue underline on my object.</p>
  
  <p>VS2012 using WinRT.</p>
  
  <p>What am I doing wrong?</p>
  
  <p>Here is the code I am using :</p>
  
  <pre><code>public class WheelPanel : Panel
  {
      public enum ItemAlignmentOptions
      {
          Left, Center, Right
      }
  
      /// &lt;summary&gt;
      /// Identifies the &lt;see cref="ItemAlignment" /&gt; dependency property.
      /// &lt;/summary&gt;
  
      // This fails using null
  
      //public static readonly DependencyProperty ItemAlignmentProperty = DependencyProperty.Register(
      //    ItemAlignmentPropertyName,
      //    typeof(ItemAlignmentOptions),
      //    typeof(WheelPanel),
      //    new PropertyMetadata(null,new PropertyChangedCallback(ItemAlignmentChanged)));
  
      // This fails using a default value
  
      //public static readonly DependencyProperty ItemAlignmentProperty = DependencyProperty.Register(
      //    ItemAlignmentPropertyName,
      //    typeof(ItemAlignmentOptions),
      //    typeof(WheelPanel),
      //    new PropertyMetadata(ItemAlignmentOptions.Center,new PropertyChangedCallback(ItemAlignmentChanged)));
  
      // This works!
      public static readonly DependencyProperty ItemAlignmentProperty = DependencyProperty.Register(
          ItemAlignmentPropertyName,
          typeof(ItemAlignmentOptions),
          typeof(WheelPanel),
          new PropertyMetadata(new PropertyChangedCallback(ItemAlignmentChanged)));
  
      /// &lt;summary&gt;
      /// The &lt;see cref="ItemAlignment" /&gt; dependency property's name.
      /// &lt;/summary&gt;
      public const string ItemAlignmentPropertyName = "ItemAlignment";
  
      /// &lt;summary&gt;
      /// Gets or sets the value of the &lt;see cref="ItemAlignment" /&gt;
      /// property. This is a dependency property.
      /// &lt;/summary&gt;
      public ItemAlignmentOptions ItemAlignment
      {
          get { return (ItemAlignmentOptions)GetValue(ItemAlignmentProperty); }
          set { SetValue(ItemAlignmentProperty, value); }
      }
  </code></pre>