How to create a UserControl <T> in C #?
Possible duplicate:
Is it possible to create a common control in .Net 3.5?
How to create UserControl<T>in C # in Winforms or Webforms?
public partial class MyView<T> : UserControl
{
public MyView()
{
InitializeComponent();
}
}
When I try this, I get the following error message:
The name 'InitializeComponent' does not exist in the current context
Can't create a shared UserControl suite in .NET 3.5?
+3
2 answers
Short answer: no!
Xaml just can't handle it in .NET 3.5. However, you can get general classes, therefore
public partial class MyView : MyView<T>
But you need to specify it in Xaml, as well as with TypeArgument
<my:BusinessObject x:TypeArguments="x:String"/>
+3