Reputation: 10659
I know I can declare an array of string in XAML like this:
<x:Array Type="{x:Type System:String}">
<System:String> first </System:String>
<System:String> second </System:String>
<System:String> third </System:String>
</x:Array>
How can I declare an array of System.Collections.Specialized.StringDictionary in XAML
<x:Array Type="{x:Type Specialized:StringDictionary}">
<Specialized:StringDictionary>
(((what do I put here?)))
</Specialized:StringDictionary>
</x:Array>
Thanks!
Upvotes: 0
Views: 1716
Reputation: 80805
Nothing. You can't do that in XAML.
There is only one way to populate a StringDictionary: call its Add(string,string)
method.
XAML does not allow to call methods. Only assign properties, and, as a special case, populate collections that implement ICollection<T>
, which StringDictionary doesn't.
Upvotes: 1
Reputation: 6501
No built in way to support it but two options to get you close.
If you are on .NET 4 and are NOT compiling your XAML (highly unlikely) you can do something like this
Again, this is really not a viable solution for most but it is possible.
More than likely you will want to create a custom markup extension to support generic collection initialization. Something like this:
adapt his last solution to include key and value and it should get where you want, sort of
Upvotes: 0