title: WPF binding problem
body: <p>I've got a problem with binding in XAML/WPF.
  I created Action class which extends FrameworkElement. Each Action has list of ActionItem. The problem is that the Data/DataContext properties of ActionItem are not set, so they are always null.</p>
  
  <p>XAML:</p>
  
  <pre><code>&lt;my:Action DataContext="{Binding}"&gt;
      &lt;my:Action.Items&gt;
          &lt;my:ActionItem DataContext="{Binding}" Data="{Binding}" /&gt;
      &lt;/my:Action.Items&gt;
  &lt;/my:Action&gt;
  </code></pre>
  
  <p>C#:</p>
  
  <pre><code>public class Action : FrameworkElement
  {
      public static readonly DependencyProperty ItemsProperty =
          DependencyProperty.Register("Items", typeof(IList), typeof(Action), 
                                      new PropertyMetadata(null, null), null);
  
      public Action()
      {
          this.Items = new ArrayList();
          this.DataContextChanged += (s, e) =&gt; MessageBox.Show("Action.DataContext");
      }
  
      public IList Items
      {
          get { return (IList)this.GetValue(ItemsProperty); }
          set { this.SetValue(ItemsProperty, value); }
      }
  }
  
  public class ActionItem : FrameworkElement
  {
      public static readonly DependencyProperty DataProperty =
          DependencyProperty.Register("Data", typeof(object), typeof(ActionItem),
              new PropertyMetadata(
                  null, null, (d, v) =&gt;
                  {
                      if (v != null)
                          MessageBox.Show("ActionItem.Data is not null");
                      return v;
                  }
              ), null
          );
  
      public object Data
      {
          get { return this.GetValue(DataProperty); }
          set { this.SetValue(DataProperty, value); }
      }
  
      public ActionItem()
      {
          this.DataContextChanged += (s, e) =&gt; MessageBox.Show("ActionItem.DataContext");
      }
  }
  </code></pre>
  
  <p>Any ideas?</p>