I would like create generic behavior. My problem is generic declaration in XAML.
public class GenericBehavior<T> : Behavior<DataGrid>
where T : class
{
}
I can’t use x:TypeArguments because I don’t have loose XAML file.
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
I found some workaround with MarkupExtension but with Behaviors not work.
In my current solution I attach behavior in code.
Any idea?
来源:https://stackoverflow.com/questions/23313622/generic-behavior