title: Generic Behavior
body: <p>I would like create generic behavior. My problem is generic declaration in XAML.</p>
  
  <pre><code>    public class GenericBehavior&lt;T&gt; : Behavior&lt;DataGrid&gt;
          where T : class 
      {
      }
  </code></pre>
  
  <p>I can’t use <a href="http://msdn.microsoft.com/library/ee956431%28v=vs.100%29.aspx" rel="nofollow noreferrer">x:TypeArguments</a> because I don’t have loose XAML file.</p>
  
  <blockquote>
    <p>In WPF and when targeting .NET Framework 4, you can use XAML 2009
    features together with x:TypeArguments but only for loose XAML (XAML
    that is not markup-compiled). Markup-compiled XAML for WPF and the
    BAML form of XAML do not currently support the XAML 2009 keywords and
    features</p>
  </blockquote>
  
  <p>I found some <a href="http://blogs.msdn.com/b/mikehillberg/archive/2006/10/06/limitedgenericssupportinxaml.aspx" rel="nofollow noreferrer">workaround</a> with MarkupExtension but with Behaviors not work.</p>
  
  <p>In my current solution <a href="https://stackoverflow.com/questions/10422385/attach-behavior-in-code-behind">I attach behavior in code</a>.</p>
  
  <p>Any idea?</p>