DataGridComboBoxColumn的绑定有关问题,大家帮小弟我看看
DataGridComboBoxColumn的绑定问题,大家帮我看看XML codetoolkit:DataGridComboBoxColumnHeaderStates
DataGridComboBoxColumn的绑定问题,大家帮我看看
XML code <toolkit:DataGridComboBoxColumn Header="States" Width="80" IsReadOnly="False" SelectedItemBinding="{Binding Path=States}" DisplayMemberPath="{Binding Path=States}"> <toolkit:DataGridComboBoxColumn.ItemsSource> <col:ArrayList> <sys:String>正常</sys:String> <sys:String>禁用</sys:String> </col:ArrayList> </toolkit:DataGridComboBoxColumn.ItemsSource> </toolkit:DataGridComboBoxColumn>
想通过States为0和1来绑定到DataGrid上,可是加载的时候有下拉,但是数值没有绑定上去
该如何绑定呢?
[解决办法]你这个binding不对。
States是什么东西?
public State
{
public Name{get;set;}
public Id{get;set;}
public State(string name,string id)
{
Name=name;
Id=id;
}
}
///
private List<state> states=new List<State>(){new State("正常","0"),new State("禁用","1")};
public List States
{
get
{
return states;
}
}
public State SelectedState
{
get{return selectedState;}
set{selectedState=vale;
NotifyChanged("SelectedState");}
}
<toolkit:DataGridComboBoxColumn Header="States" Width="80" IsReadOnly="False"
ItemsSource="{Binding Path=States}" DisplayMemberPath="{Binding Path=Name}" SelectedItem={Binding SelectedState}>
</toolkit:DataGridComboBoxColumn>