title: WPF Ordering DataBinding in nested user controls
body: <p>I have two user controls: 'Flags' and 'FlagOption'.  'FlagOption' is nested in an ItemsControl in the 'Flags' control like so:</p>
  
  <p>Flags Control:</p>
  
  <pre><code>&lt;ItemsControl ItemsSource="Binding RelativeSource={RelativeSource AncestorType=local:Flags}, Path=FlagOptions}"&gt;
      &lt;ItemsControl.ItemTemplate&gt;
          &lt;DataTemplate&gt;
              &lt;local:FlagOption FlagValue="{Binding}" Field="{Binding RelativeSource={RelativeSource AncestorType=local:Flags}, Path=Field}" /&gt;
          &lt;/DataTemplate&gt;
      &lt;/ItemsControl.ItemTemplate&gt;
  &lt;/ItemsControl&gt;
  </code></pre>
  
  <p>CodeBehind:</p>
  
  <pre><code>public static readonly DependencyProperty FieldProperty = DependencyProperty.Register(nameof(Field), typeof(TagInterface.LongFlags), typeof(Flags));
  
  public TagInterface.LongFlags Field
  {
      get { return (TagInterface.LongFlags)GetValue(FieldProperty); }
      set { SetValue(FieldProperty, value); }
  }
  
  public IEnumerable&lt;Enum&gt; FlagOptions
  {
      get
      {
          return Enum.GetValues(Field.FieldValue.GetType()).Cast&lt;Enum&gt;();
      }
  }
  </code></pre>
  
  <p>FlagOption Control:</p>
  
  <pre><code>&lt;CheckBox FlowDirection="LeftToRight" IsChecked="{Binding Path=IsChecked, RelativeSource={RelativeSource AncestorType=local:FlagOption}}"/&gt;
  </code></pre>
  
  <p>CodeBehind:</p>
  
  <pre><code>public static readonly DependencyProperty FlagValueProperty = DependencyProperty.Register(nameof(FlagValue), typeof(Enum), typeof(FlagOption));
  public static readonly DependencyProperty FieldProperty = DependencyProperty.Register(nameof(Field), typeof(TagInterface.LongFlags), typeof(FlagOption));
  
  public Enum FlagValue
  {
      get { return (Enum)GetValue(FlagValueProperty); }
      set { SetValue(FlagValueProperty, value); }
  }
  
  public TagInterface.LongFlags Field
  {
      get { return (TagInterface.LongFlags)GetValue(FieldProperty); }
      set { SetValue(FieldProperty, value); }
  }
  
  public bool IsChecked
  {
      get
      {
          // Accessing Field Property here is null because it is bound AFTER IsChecked field
          return false;
      }
      set
      {
          // TODO
      }
  }
  </code></pre>
  
  <p>The problem I'm having is that in the FlagOption control the "Field" Dependency Property is being bound AFTER the IsChecked Property, so the Field property is null in the Getter of the IsChecked property.  If debug and step over the error the "Field" Dependency property eventually gets bound, but it's too late.</p>
  
  <p>Can I control the order of the binding somehow?  Why isn't the Field Dependency Property binding before my IsChecked Property?</p>