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
2275
Two way binding to a XamComboEditor
posted

I have a number of combo boxes in a window that I need to setup two-way binding on, however I can't seem to figure out how to do it.  I have successfully set up basic binding to fill the control where I have the ItemsSource="{Binding}" and I set my DataContext in my C# code behind.  I also have two-way binding working on all of the other controls in the window

Let's say I have an object and I am returning an ObservableCollection of it and I want to display Name which is a string.  I want the value member to be an ID which is an integer.  Is there a code snipped you can please provide that shows how to do two way binding on the ID?  I can't seem to find a ValueMember property anywhere, and basically XamComboBox binding is a mystery for me.

Thank you for a very simple and basic xaml code snippet.

Parents
No Data
Reply
  • 30945
    Offline posted

    Hello Mike,

     

    I have been looking into the functionality that you are looking for and the XamComboEtidor have a ValuePath property which provides a two way binging to the value of the cell in which the editor is used. For example, you have the following scenario: you have an int field called ItemID which represents a int property in you data source and you wish to display string representation of the integer value of this field. You create class called Item that have a Name and ID properties and you create an ObservableCollection<Item> and set it as ItemsSource to a XamComboEdtior used in the ItemID field. You are setting the DisplayPath to Name in order to display name of the item instead of the integer value of the cells in the field. When you set the ValuePath to ID you will create a two way binging between the ID property of the SelectedItem of the XamComboEditor and the property that is represented by the Cell in which the XamComboEditor is displayed. I have created a sample application that demonstrates the described scenario.

     

    Please let me know if this is what you are looking for or I have misunderstood you in any way.

     

    Looking forward to hearing from you.

     

    Sincerely,

    Krasimir

    Developer Support Engineer

    Infragistics

    www.infragistics.com/support

    DataGridWithCombo_2.zip
Children