为什么BindingSource组件看不到继承的属性? [英] Why BindingSource component cannot see inherited properties?

查看:79
本文介绍了为什么BindingSource组件看不到继承的属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经定义了类:

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:

https://connect.microsoft.com/VisualStudio/feedback/details/431273/interface-inheritance-bug

这篇关于为什么BindingSource组件看不到继承的属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆