is there a way to have a WPF UserControl Class to be a class with a Template type?
e.g.
public partial class MyControl : UserControl
should be:
public partial class MyControl<MyData> : UserControl
as I always get compile errors that MyControl than has no reference to InitializeComponents which is in the automatic generated part of the class.
The problem is, that I can’t tell in the xaml part of the class that the usercontrol is of type MyControl<MyData>. I even tried MyControl<MyData> …
No, you can’t declare a generic type in XAML. From http://social.msdn.microsoft.com/forums/en-US/wpf/thread/02ca0499-80af-4c56-bb80-f1185a619a9e:
You can create a control in XAML that inherits from a generic type by putting a
x:TypeArgumentsattribute on the root tag, but the control itself must be concrete.