C#
MainDataContext db = new MainDataContext();
var cat = from p in db.Categories
select p;
categoriesComboBox.ItemsSource = cat;
categoriesComboBox.SelectedValuePath = "ID";
categoriesComboBox.DisplayMemberPath = "CatName";
XAML
<Custom:DataGridComboBoxColumn
Width="1*" x:Name="categoriesComboBox"
Header="Category"
ItemsSource="{Binding}"
SelectedValueBinding="{Binding Path=Category}"
SelectedValuePath="ID"
DisplayMemberPath="CatName"
/>
现在的事情是我可以在加载时在组合框中看到名称...当我单击组合框时,下拉菜单会显示每个项目的 MainDataContext.Category...
当我单击任何下拉项目时..它选择正确的值并..在组合框中显示我...