O'Reilly logo

XAML Unleashed by Adam Nathan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Dictionary Keys of Any Type

In XAML2009, type conversion is attempted with x:Key values, so you can successfully add items to a dictionary with nonstring keys without using a markup extension. Here’s an example:

<collections:Dictionary x:TypeArguments="x:Int32, x:String">  <x:String x:Key ="1 " >One</x:String>  <x:String x:Key ="2 " >Two</x:String></collections:Dictionary>

Here, collections is assumed to map to the System.Collections.Generic namespace.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required