title: Accessing a resource via codebehind in WPF
body: <p>I have a custom collection defined in my window resources as follows (in a Sketchflow app so the window is actually a UserControl):</p>
  
  <pre><code>&lt;UserControl.Resources&gt;
      &lt;ds:MyCollection x:Key="myKey" x:Name="myName" /&gt;
  &lt;/UserControl.Resources&gt;
  </code></pre>
  
  <p>I want to be able to refer to this collection in the codebehind, which I expected would be by the x:Name, but I can't seem to access it. </p>
  
  <p>I can get a reference to it using</p>
  
  <pre><code>myRef = (MyCollection) this.FindName("myKey");
  </code></pre>
  
  <p>but this seems hackish. Is this bad practice, and what would be better? Thanks :)</p>