C# WPF双向数据绑定问题

C# WPF双向数据绑定问题,c#,wpf,data-binding,C#,Wpf,Data Binding,因此,我试图以编程方式为动态生成的选项卡创建双向绑定,而路径需求给我带来了麻烦 当我不使用双向绑定并删除路径/源/模式/触发器时进行编辑它工作正常 以下是我正在使用的绑定: Binding schedBind = new Binding(); schedData = Converter.GetTemplate(false); schedGrid.DataContext = schedData; schedBind.Path = new PropertyPath(DataGrid.DataCont

因此,我试图以编程方式为动态生成的选项卡创建双向绑定,而路径需求给我带来了麻烦

当我不使用双向绑定并删除路径/源/模式/触发器时进行编辑它工作正常

以下是我正在使用的绑定:

Binding schedBind = new Binding();
schedData = Converter.GetTemplate(false);
schedGrid.DataContext = schedData;
schedBind.Path = new PropertyPath(DataGrid.DataContextProperty);
schedBind.RelativeSource = new RelativeSource(RelativeSourceMode.Self);
schedBind.Mode = BindingMode.TwoWay;
schedBind.UpdateSourceTrigger = UpdateSourceTrigger.Explicit;
schedGrid.SetBinding(DataGrid.ItemsSourceProperty, schedBind);
但是,当我创建使用
DataGrid schedGrid
的选项卡实例时,它显示为空。
DataTable schedData
中确实包含信息,那么为什么绑定没有填充
DataGrid


帮助?

我通过添加一个类
DataHolder
修复了它,该类具有
SchedData
属性。然后,我将
DataHolder
的实例设置为
DataContext
,并设置
Path=SchedData

这不完全是我所希望的,但它起作用了