title: WPF: ComboBox, comparing objects based on identifying property
body: <p>Let's say I have a Class, let's name it Parent. This class has as a property a object of another class, let´s call it Child. Child has a int property ID.</p>
  
  <p>Now instances of these classes are based on rows in database tables.</p>
  
  <p>So let's say Parent has Child instance with ID=4 and in my program there will be a Dropdown list with all available Child instances so we can change the instance in Parent.</p>
  
  <p>Problem is that because of bad design the list with all the child objects is instanced on a seperate occasion from the Child inside the parent so even if they both have ID=4 it won't recognize them as same object ( because of course it isn't ).</p>
  
  <p>However I still wan't the same ID object being the default one for the ComboBox. I should somehow of course just reference the ID somehow but I'm a little bit slow in the dark month of december and I'm not seeing how to do it because it's still the object I'm setting not only int value.</p>
  
  <p>Here is the XAML code:</p>
  
  <pre><code> &lt;DataTemplate x:Key="EditTemplate" DataType="{x:Type data:Parent}"&gt;
        &lt;ComboBox ItemsSource="{Binding ElementName=Panel, Path=DataContext.ChildList}"
                                SelectedItem="{Binding Path=Child, Mode=TwoWay}"
                                SelectedValuePath="ID" DisplayMemberPath="Name" /&gt;
   &lt;/DataTemplate&gt;
  </code></pre>