Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1865
Binding XamComboEditor to Dictonary in code-behind
posted

All my binding code is in code-behind. I am using:

this.cboPB.ItemsSource = MyClass.Instance.MyDictionary();            

this.cboPB.DisplayMemberPath = "Value";            

this.cboPB.SelectedItem = "Key"; // THIS IS NOT AVAILABLE - HOW DO IDO THIS?

 

The dictionary referenced above is defined as type MyDictionary<int, string>();

Please help. Thanks.

  • 17475
    Offline posted

    Hello Jay and thank you for posting! 

    XamComboEditor expects an object of the source type for the SelectedItem. In this case, as you are using a dictionary, an element from the dictionary could be set like this: cboPB.SelectedItem = dict.ElementAt(1);

    I have attached a sample project regarding the same. Please let me know if you need additional assistance.

    XamComboEditorDictionary.zip