http://stackoverflow.com/questions/33175983/how-to-select-item-displayed-by-displaymemberpath-in-wpf-combobox/42412423#42412423
Code of which is as follows:
cmb_Class.ItemsSource = from c in Container.Classes select new {ClassID = c.Class_Id};
cmb_Class.DisplayMemberPath = "ClassID";
I had used DisplayMemberPath so that I can only get the assigned value.
But,
The problem is that when I select an item from the dropdown menu, instead of that item the whole string is shown as selected item in the Combobox.
The solution is to add ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}" into the <ContentPresenter x:Name="ContentSite" line of the Xaml.
Comments: ** Comment from web user: BoucherS **
Hi,
Can you please elaborate on this ?
The XAML of the WatermarkComboBox doesn't contains a ContentPresenter with " x:Name="ContentSite"".
Which version of the Toolkit are you using ?
In 3.3, this bug is not present.
Also tried with v3.0 and bug is not present.
Here's the sample used :
```
<xctk:WatermarkComboBox x:Name="cmb_Class" />
```
```
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
cmb_Class.ItemsSource = new List<MyData>() { new MyData() { ClassID = 1 }, new MyData() { ClassID = 2 }, new MyData() { ClassID = 3 } };
cmb_Class.DisplayMemberPath = "ClassID";
}
}
public class MyData
{
public int ClassID
{
get;
set;
}
}
```
――――
_Get more controls, features, updates and technical support with [Xceed Toolkit Plus for WPF](https://wpftoolkit.codeplex.com/wikipage?title=Compare%20Editions)_