An 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>
+3
source share
1 answer

You need to use a different namespace prefix. x:Typeis the 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 when using element syntax, so you need to pass a type 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>
+4
source

Source: https://habr.com/ru/post/1756678/


All Articles