title: Inject VM to custom control in WPF using Unity
body: <p>I am building a WPF based application. I am using Unity to inject all the different dependencies in my application (defined in App.xaml.cs).
  In my MainApplication window I have a pretty complex look-less custom control derived from Control(is has about ten more control integrated in it).
  I would like to inject a VM into this custom control without coupling it to any other object in my application (except App.xaml.cs of course)</p>
  
  <p>Injection to any WPF window in my application works well, but when I try injecting to the custom control I am facing to different situation:
   1. In case I am using 
  container.RegisterInstance(container.Resolve);</p>
  
  <p>The DI creates a dummy instance of MyCustomControl and injects the VM (using [Dependency] attribute). However this specific instance is not used when I use it in my XAML:</p>
  
  <p></p>
  
  <p>in which case it initializes a new MyCustomControl ignoring any dependencies.</p>
  
  <ol>
  <li>In case I am using 
  container.RegisterType();</li>
  </ol>
  
  <p>The MyCustomControl completely ignores the injection.</p>
  
  <p>I realize I am probably doing something wrong (not just technically) and I am really trying to avoid coupling this control (which will obviously solve the issue).</p>