0

I have a WPF custom combo box that is for selecting Contacts. I'd like to expose multiple ways of interfacing with the combo box's selected item and I'd like them to be bindable.

public class ContactComboBox : ComboBox {
    public ContactJson SelectedContact {get; set;}
    public long? SelectedContactId {get; set; }
}

I know how to handle single properties that bind to single values with dependency properties, but how do I have a change in one property affect the change in another?

For example:

<local:ContactComboBox SelectedContactId="{Binding ContactId}" />

When the ContactID on the datasource is changed, both the SelectedContact and SelectedContactId values should be changed.

Thanks for your help!

Tony Valenti
  • 11
  • 1
  • 9
  • 1
    Possible duplicate of [Difference between SelectedItem, SelectedValue and SelectedValuePath](https://stackoverflow.com/questions/4902039/difference-between-selecteditem-selectedvalue-and-selectedvaluepath) – ASh Oct 10 '17 at 16:22
  • 2
    Create two dependency properties. In the PropertyChangedCallback of one property just update the other and vice versa. – Clemens Oct 10 '17 at 17:13

0 Answers0