title: Static Resources in WPF
body: <p>I have a class in WPF that is referenced in XAML as a view control:</p>
  
  <pre><code>&lt;ctrl:MyController x:Key="Controller"/&gt;
  </code></pre>
  
  <p>I can now access this as a static resource and all is fine:</p>
  
  <pre><code>Command="{Binding Source={StaticResource Controller}, Path=HistoryFutureRetrieveLeft,
  Mode=OneTime}"&gt;
  </code></pre>
  
  <p>However I now need to create the controller using an IOC container. I can do this with the following code:</p>
  
  <pre><code>Resources.Add("Controller", App.IocContainer.Resolve&lt;MyController&gt;());
  </code></pre>
  
  <p>But I have to remove the line from the XAML,:</p>
  
  <pre><code>&lt;ctrl:MyController x:Key="Controller"/&gt;
  </code></pre>
  
  <p>This isn't a problem at run time but this does cause a problem when trying to edit the XAML because all the bindings now say the "Resource Controller is not found". Is there any way to allow the IOC container to create the controller at run time but to define the controller in the XAML file purely for the VS designer?</p>