我試圖將一個WinForms項目移植到WPF。但是我在數據綁定方面遇到了一些麻煩。從WinForm移植到WPF,數據綁定的問題
我的WinForms程序有哪些形式的數據綁定組合框
His **Data** properties:
DataPropertyName **Developer**
DataSource **developerBindingSource1**
DataMember **DeveloperName**
ValueMember **Developer**
而接下來的代碼
developerBindingSource1.DataSource = DT.Developer;
taskBindingSource.DataSource = DT.Task;
typeTaskBindingSource.DataSource = DT.TypeTask;
developBindObjBindingSource.DataSource = DevelopBindObj.GetBindingList(DT.Developer);
typeTaskBindObjBindingSource.DataSource = TypeTaskBindObj.GetBindingList(DT.TypeTask);
我使用其他類綁定
class DevelopBindObj
{
public Developer Developer { get; private set; }
public string DeveloperName
{
get
{
return this.Developer.FIO;
}
}
private DevelopBindObj(Developer Developer)
{
this.Developer = Developer;
}
public static IBindingList GetBindingList(IEnumerable<Developer>Developers) {BindingList<DevelopBindObj> result = new BindingList<DevelopBindObj>();
foreach (var ee in Developers)
{
result.Add(new DevelopBindObj(ee));
}
return result;
}
,並使用列的DataGrid我怎麼能在WPF中做到這一點?
我已經試過:
<DataGridComboBoxColumn x:Name="iDTypeTaskColumn"
Header="IDType Task"
Width="SizeToHeader"
SelectedValuePath="{Binding Source={StaticResource bindObjectsTaskViewSource}, Path=TypeTask}"
DisplayMemberPath="{Binding Source={StaticResource bindObjectsTaskViewSource}, Path=TypeTaskName}"
ItemsSource="{Binding Source={StaticResource bindObjectsTaskViewSource}}" SelectedItemBinding="{Binding Path=tblDevTypeTask}">
但是,這是行不通的。