title: DependencyProperty Default Value
body: <p>I'm trying to get a DependencyProperty working in WPF. I'm using:</p>
  
  <pre><code>public static readonly DependencyProperty DisplayModeProperty = DependencyProperty.Register("DisplayMode", typeof (TescoFoodSummary), typeof (Orientation), new UIPropertyMetadata(Orientation.Vertical));
      /// &lt;summary&gt;
      /// Gets or sets the orientation.
      /// &lt;/summary&gt;
      /// &lt;value&gt;The orientation.&lt;/value&gt;
      public Orientation DisplayMode {
          get { return (Orientation)base.GetValue(DisplayModeProperty); }
          set { base.SetValue(DisplayModeProperty, value); }
      }
  </code></pre>
  
  <p>When I initialize the window, I get an error: Default value type does not match type of property 'DisplayMode'. Howevere, if I leave the default value out I get a null reference exception when the window loads due to DisplayModeProperty not being set.</p>