Is it possible to use WPF user control with generics?

I would like to create my own WPF control using generics:

public class MyGenericTypeControl<T> : ItemsControl { // ... } 

Can this be done? In my initial experiment, I get development-time / compile-time XAML errors as soon as I try to add this control somewhere. This is not surprising since building my user control requires additional information that XAML does not provide.

Any ideas?

+7
source share
2 answers

This is not fully supported in XAML. See this blog post on MSDN .

+5
source

XAML does not support generics, you need to create an empty non-generic class that inherits from your common control and use it with XAML

+3
source

All Articles