绑定到嵌套属性很容易:
checkBox1.DataBindings.Add(new Binding("Checked", bindingSource, "myProperty")); //Normal binding
checkBox2.DataBindings.Add(new Binding("Checked", bindingSource, "myProperty.innerProperty")); //Nested property
Run Code Online (Sandbox Code Playgroud)
但是,myProperty.innerProperty更改时,不会引发任何事件 - BindingSource永远不会收到更改通知.
我已经读过,解决方案是"确保当innerProperty对象引发PropertyChanged事件时,MyProperty包含的类innerProperty捕获事件并引发PropertyChanged自己的事件."
但是,实体框架并没有为我做这个,我宁愿不经历每个类的每个实例,并将自定义方法连接到每个导航属性,只是为了使我的类可绑定. 是否有一个体面的解决方法来使实体可绑定?