我已经定义了类:
public class Parent : IParent { public string ParentText { get { return "ParentText"; } } } public interface IParent { string ParentText { get;} } public class Child : Parent, IChild { public string ChildText { get { return "ChildText"; } } } public interface IChild : IParent { string ChildText { get;} }当我尝试将控件绑定到IChild实例时,可以对ChildText属性执行此操作,但对于ParentText属性则不能执行此操作。如果我尝试绑定到Child实例,则两个属性都是可绑定的。 为什么数据绑定机制看不到从其他接口继承的属性?
When I try to bind control to IChild instance, I can do this for ChildText property, but not for ParentText property. if I try to bind to Child instance, both properties are bindable. Why databinding mechanism does not see properties inherited from other interfaces?
编辑:SharePoint Newbie是正确的:通过手工代码定义数据绑定有效。但是,我尝试使用BindingSource组件在设计器中定义数据绑定。当您将对象源添加到项目中并将其指向IChild接口时,只有ChildText可见才能定义绑定。
SharePoint Newbie is right: databindings work when defined by hand in code. However, I tried to define databindings in designer using BindingSource component. When you add object source to project and point it to IChild interface, only ChildText is visible to define bindings.
我更新了问题标题以更好地反映我的问题。
I updated title of question to better reflect my problem.
推荐答案我认为,框架中存在一个导致描述问题的错误。这是相关的连接问题:
I think, there is a bug in framework which causes described issue. Here is relevant connect issue:
connect.microsoft/VisualStudio/feedback/details/431273/interface-inheritance-bug
更多推荐
为什么BindingSource组件看不到继承的属性?
发布评论