Generics support in XAML
Support for creating generic classes in XAML is still lacking. The only XAML element that lets you specify the generic type argument is only the root element of the user control. I couldn’t find any way to create an instance of a generic class in XAML yet. One had a class called “NameValue” in the project and wanted to be able to create an ObservableCollection<NameValue> in XAML. The only way I was able to do it in XAML was to create another empty class called NameValueCollection that inherited from ObservableCollection<NameValue> and then create an instance of the “NameValueCollection” in XAML instead.
public class NameValueCollection : ObservableCollection<NameValue>
{
}
I think one way generics could be supported in XAML is by creating new MarkupExtensions for that purpose.
Vish,
Actually you’re on the right track. While doing my own research on XAML generic support, I ran into with the description of a MarkUpExtension implementation for limited generic support in XAML.
Enjoy.
Vish,
Actually you’re on the right track. While doing my own research on XAML generic support, I ran into this post with the description of a MarkUpExtension implementation for limited generic support in XAML.
Enjoy.