【问题标题】:Why can't I derive from GridViewRowPresenterBase?为什么我不能从 GridViewRowPresenter Base 派生?
【发布时间】:2012-10-04 00:33:07
【问题描述】:

为什么我不能从 GridViewRowPresenterBase 派生?

public class GridViewRowPresenterEx : GridViewRowPresenterBase
{
    protected override void OnColumnPropertyChanged(GridViewColumn c, string s)
    {
    }
}

我收到以下编译错误:

'GridViewRowPresenterEx' 没有实现继承的抽象成员 System.Windows.Controls.Primitives.GridViewRowPresenterBase.OnColumnPropertyChanged(System.Windows.Controls.GridViewColumn, 字符串)'

'GridViewRowPresenterEx.OnColumnPropertyChanged(System.Windows.Controls.GridViewColumn, string)': 找不到合适的方法来覆盖

【问题讨论】:

    标签: c# .net wpf


    【解决方案1】:

    GridViewRowPresenterBase暴露的OnColumnPropertyChanged()方法是internal abstract(可以在源代码here看到)。

    不幸的是,there is no way 在其原始程序集之外实现了 internal abstract 方法。看起来GridViewRowPresenterBase 被设计为只能由PresentationFramework.dll 中的其他类派生。

    【讨论】:

    • 如果他们将实例构造函数的可访问性从 protected 更改为 internal,将会很有帮助。这将发出一个信号“我们考虑过这一点,我们不会允许从其他程序集继承”。编译器生成的默认实例构造函数默认为protected
    猜你喜欢
    • 2013-08-31
    • 1970-01-01
    • 2019-09-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-09
    相关资源
    最近更新 更多