Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using generic types in XAML x:Type markup [duplicate]

I have the following XAML snippet and I want to include a generic parameter and I can't work out what I need to do?

I guess I'm going to have to created a markup extension to do this but I'm unsure how to get this to work with the x:Type attribute.

DataType="{x:Type vm:FooViewModel<Bar>}"
like image 494
AwkwardCoder Avatar asked Dec 10 '13 13:12

AwkwardCoder


People also ask

What is generic XAML?

xaml file itself, the dictionary entry within generic. xaml can be a merged dictionary whose entries may reference anything.

What is X type in WPF?

WPF supports techniques that enable specifying the value of some properties of type Type without requiring an x:Type markup extension usage. Instead, you can specify the value as a string that names the type. Examples of this are ControlTemplate.

What is generic type arguments?

The generic argument list is a comma-separated list of type arguments. A type argument is the name of an actual concrete type that replaces a corresponding type parameter in the generic parameter clause of a generic type. The result is a specialized version of that generic type.


1 Answers

Check the Generics in XAML documentation to see if it fits your scenario. You'd need to use x:TypeArguments; there are however some restrictions that you can check in the linked reference pages.

like image 103
jnovo Avatar answered Sep 18 '22 06:09

jnovo