title: WPF - Can only base on a Style with target type that is base type
body: <p>This is sending me nuts, mostly because at runtime it works perfectly (the problem only appear at design time), but I decided to ask anyway as I'm working on a big project and I want to implement things the best way.</p>
  
  <p>First thing: I have a component from a third part library, it is basically like a border, and it's defined this way (with F12):</p>
  
  <pre><code>public class AdvancedBorder : ContentControl
  </code></pre>
  
  <p>I like the visual aspect of this thing, but I need to add some functionalities. So I created a new Custom Control: </p>
  
  <pre><code>public class SelectableCard : AdvancedBorder
  {
      // bunch of custom properties and stuff
  
      static SelectableCard()
      {
          DefaultStyleKeyProperty.OverrideMetadata(typeof(SelectableCard), new FrameworkPropertyMetadata(typeof(SelectableCard)));
      }
  }
  </code></pre>
  
  <p>Finally I need to keep the exactly same visual but adding some triggers, so I put this in generic.xaml:</p>
  
  <pre><code>&lt;Style TargetType="{x:Type customControls:SelectableCard}" BasedOn="{StaticResource ResourceKey={x:Type otherLibrary:AdvancedBorder}}"&gt;
      &lt;Setter Property="HorizontalAlignment" Value="Stretch"/&gt;
      &lt;Setter Property="VerticalAlignment" Value="Stretch"/&gt;
      &lt;Style.Triggers&gt;
          &lt;Trigger Property="customControls:SelectableCard.IsSelected" Value="True"&gt;
              &lt;Setter Property="Background" Value="{DynamicResource MyLightBrush}" /&gt;
          &lt;/Trigger&gt;
      &lt;/Style.Triggers&gt;
  &lt;/Style&gt;
  </code></pre>
  
  <p><code>customControls</code> is the xmlns for my namespace, <code>otherLibrary</code> is the xmlns for the third part library.</p>
  
  <p>Everything works perfectly fine at runtime, and gives no errors at all. At design time I get no errors from the generic.xaml, but as soon as I put the SelectableCard in some xaml file, I get</p>
  
  <blockquote>
    <p>Can only base on a Style with target type that is base type
    SelectableCard</p>
  </blockquote>
  
  <p>And I don't get it at all, especially as it works at runtime. I can remove the <code>BasedOn</code> attribute and I get no more complaints at design time, but then I have to add the setter for the template otherwise I can't see anything at runtime.</p>
  
  <p>What am I doing wrong, here?</p>