title: WPF UserControl with DependencyObject binding
body: <p>Here's what I want to accomplish:</p>
  
  <pre><code>&lt;ctrl:MyControl x:Name="mc"&gt;
      &lt;ctrl:MyControl.MyData&gt;
          &lt;ctrl:MyDataCollection&gt;
              &lt;ctrl:MyData MyProperty="{Binding PropertyA}"/&gt;
              &lt;ctrl:MyData MyProperty="{Binding PropertyB}"/&gt;
          &lt;/ctrl:MyDataCollection&gt;
      &lt;/ctrl:MyControl.MyData&gt;
  &lt;/ctrl:MyControl&gt;
  </code></pre>
  
  <p>MyDataCollection is simply:</p>
  
  <pre><code>public class MyDataCollection : List&lt;MyData&gt;
  {
  };
  </code></pre>
  
  <p>And MyData:</p>
  
  <pre><code>public class MyData : DependencyObject
  {
  
      public MyData()
      {
  
      }
  
      public double MyProperty
      {
          get { return (double)GetValue(MyPropertyProperty); }
          set { SetValue(MyPropertyProperty, value); }
      }
  
      public static readonly DependencyProperty MyPropertyProperty =
          DependencyProperty.Register("MyProperty", typeof(double), typeof(MyData), new PropertyMetadata(0.0));
  }
  </code></pre>
  
  <p>MyCotrol contains DependencyProperty of MyDataCollection.
  Now to the point. MyDataCollection is filled correctly with MyData, problem lies with MyProperty in MyData not binding (MyProperty got default value). If I set it by hand(for instance MyProperty="5") everything works fine.</p>
  
  <p>My MVVM implements INotifyPropertyChanged, It got two Properties, PropertyA and PropertyB and is set as DataContext of MyControl.</p>
  
  <p>Any ideas what I am missing? I was able to do this with UserControl, but I can't get it to work with DependencyObject inside UserControl.</p>
  
  <p>EDIT:</p>
  
  <p>I added dependency property in MyControl, then I did:</p>
  
  <pre><code>&lt;ctrl:MyControl x:Name="mc" TestProperty ="{Binding PropertyA}"&gt;
      &lt;ctrl:MyControl.MyData&gt;
          &lt;ctrl:MyDataCollection&gt;
              &lt;ctrl:MyData MyProperty="{Binding PropertyB}"/&gt;
          &lt;/ctrl:MyDataCollection&gt;
      &lt;/ctrl:MyControl.MyData&gt;
  &lt;/ctrl:MyControl&gt;
  </code></pre>
  
  <p>And it works perfectly for TestProperty.</p>
  
  <p>Error from output panel:</p>
  
  <pre><code>System.Windows.Data Error: 2 : Cannot find governing FrameworkElement or FrameworkContentElement for target element
  </code></pre>