Thursday 30 June 2011

WPF Binding to a Dictionary

Found this useful tip recently. You can bind a WPF control to any indexed property, including dictionaries.

DataMemberBinding="{Binding MyDict[MyKey]}"

This caught me out because the syntax is very C# and I use VB.Net.

You can also do this programmatically.

DataMemberBinding = New Binding("MyDict[MyKey]")

No comments:

Post a Comment