title: Order In Chaos Of Control Initialization Steps
body: <p>I would like to know when is actually what happening inside initalization process of controls when I start a WPF application?</p>
  
  <p>When are DP initalized? When Binding? When does DataContext get set? Is DataContext avaialbe in constructor of a control? Is there any kind of order?</p>
  
  <p>I realized I ran into a trap that once I set a value on getter/setter of a DP inside constructor of a control the DP value gets updated but immediately also the values gets rolled back to default value which was null.</p>
  
  <p>So my guess is that contructors get initalized first and then dependency properties.</p>
  
  <p>Can somebody help me out with this?</p>
  
  <p>Edit: Just for Rachel. The dp receives the value 234 and immedialty rolls back to null. I think its because constructor gets called first  and then subsequently the initalizing of dps happens which sets dp back to null because null is default value. Am i thinking wrong about this? What is the order of initalization steps of a control or dependency object.</p>
  
  <pre><code>class MySuperDuperCoolClass : ContentControl
  {
    public MySuperDuperCoolClass()
    {
      InitalizeComponents();
      this.MySuperDuperProperty = "234";
    }
  
    public string MySuperDuperProperty
    {
      get { return (string)GetValue(MySuperDuperPropertyProperty);}
      set { SetValue(MySuperDuperPropertyProperty, value);}
    }
  
    public static DependencyProperty MySuperDuperPropertyProperty =
      DependencyProperty.Register("MySuperDuperProperty", typeof(string), typeof(MySuperDuperCoolClass), 
      new PropertyMetadata(null));
  
  }
  </code></pre>