我是 LightSwitch 的新手。我试图在检查复选框控件时捕获事件。在创建屏幕时,我写道:
partial void CreateNewEmployee_Created() { this.EmployeeProperty.Contractors = new Contractor(); Dispatchers.Main.BeginInvoke(() => { ((INotifyPropertyChanged) this.EmployeeProperty).PropertyChanged += new PropertyChangedEventHandler(CreateNewEmployee_PropertyChanged); }); }
并在 CreateNewEmployee_PropertyChanged 中处理事件
private void CreateNewEmployee_PropertyChanged(object sender, PropertyChangedEventArgs e) { if(this.EmployeeProperty.IsContractor) { this.EmployeeProperty.Contractors = new Contractor(); } }
我得到了例外
this.EmployeeProperty.Contractors = new Contractor();
例外是
无法初始化 EntityObject 类的新实例,因为环境 IDataWorkspace 不可用。请使用指定 EntitySet 的构造函数。
谢谢