icube
icube

Reputation: 2798

array of Type in xaml?

is there a way to declare an array of types in xaml?

maybe something like this?

 <x:Array Type="x:Type">
   <x:Type se:MyType1/> 
   <x:Type se:MyType2/> 
   <x:Type se:MyType3/>                                                                    
 </x:Array>

Upvotes: 4

Views: 5130

Answers (1)

Quartermeister
Quartermeister

Reputation: 59129

You need to use a different namespace prefix. x:Type is a markup extension that creates System.Type objects, and you want to create an array of type objects, not an array of markup extensions (I assume).

You cannot call constructors from when using element syntax, so you'll need to pass the type in using the Type property of TypeExtension.

Something like this should work:

<x:Array xmlns:sys="clr-namespace:System;assembly=mscorlib" Type="sys:Type">
    <x:Type Type="se:MyType1"/>
    <x:Type Type="se:MyType2"/>
    <x:Type Type="se:MyType3"/>
</x:Array>

Upvotes: 4

Related Questions