title: xClassNotDerivedFromElement error when adding Code Behind to Resource Dictionary in silverlight
body: <p>I need to add code behind class to Resource Dictionary as described in <a href="https://stackoverflow.com/questions/92100/is-it-possible-to-set-code-behind-a-resource-dictionary-in-wpf-for-event-handling">this question</a>. (I know that this is not a good practise but it should work based on the comments for linked question) .I'm referencing the code with x:Class attribute:</p>
  
  <p>XAML (separate Resource Dictionary file):</p>
  
  <pre><code>&lt;ResourceDictionary
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      x:Class="MyNamespace.MyStandardResources"&gt;
      ...
  &lt;/ResourceDictionary&gt;
  </code></pre>
  
  <p>CODE:</p>
  
  <pre><code>using System.Windows;
  
  namespace MyNamespace
  {
      public partial class MyStandardResources : ResourceDictionary
      {
          public MyStandardResources()
          {
              InitializeComponent();
          }
  
          //...
      }
  }
  </code></pre>
  
  <p>This causes the runtime parser exception:</p>
  
  <p>Parser internal error: Object writer '<strong>xClassNotDerivedFromElement</strong>'. [Line: xxx Position: xxx] at System.Windows.Application.LoadComponent.</p>
  
  <p>The resources are included in App.xaml with ResourceDictionary.MergedDictionaries tag.</p>