c# - WPF DataGridComboBoxColumn does not work -
i have class called person , list called people, show below:
namespace wpfapplication1 { public partial class mainwindow : window { public list<person> people; public mainwindow() { initializecomponent(); people = new list<person>(); people.add(new person() { id = 1, name = "john" }); people.add(new person() { id = 2, name = "mike" }); } } public class person { public int id { get; set; } public string name { get; set; } } } and want display 2 person in people datagrid, using combobox take between 2 person.
<datagrid x:name="datagrid1" height="300"> <datagridcomboboxcolumn header="name" displaymemberpath="name" selecteditembinding="{binding path=name}"> <datagridcomboboxcolumn.editingelementstyle> <style targettype="combobox"> <setter property="itemssource" value="{binding path=people}"/> </style> </datagridcomboboxcolumn.editingelementstyle> <datagridcomboboxcolumn.elementstyle> <style targettype="combobox"> <setter property="itemssource" value="{binding path=people}"/> </style> </datagridcomboboxcolumn.elementstyle> </datagridcomboboxcolumn> </datagrid> but datagrid display nil @ all. what's problem?
shouldnt within <datagrid.columns> tag?
c# wpf datagrid datagridcomboboxcolumn
No comments:
Post a Comment