我在 Silverlight 5 应用程序项目中添加了两个窗口:FooWindowBase
和SomeFooWindow
. 后者是前者的子类。两者都包含一个默认构造函数调用InitializeComponent
,显然 Visual Studio 或编译器会自动生成该方法。这会导致派生类中出现以下编译器警告SomeFooWindow
...</p>
“子
InitializeComponent
遮蔽了基类中声明的可重载成员FooWindowBase
。如果要重载基方法,则必须声明此方法Overloads
。”
由于InitializeComponent
在这两种情况下都是自动生成的,因此我似乎无法添加Shadows
overOverloads
说明符。
有没有办法在不编辑自动生成的代码的情况下防止或消除此编译器警告?
FooWindowBase
:
XAML:
<c:ChildWindow x:Class="FooNamespace.FooWindowBase" xmlns:c="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls" …> … </c:ChildWindow>
代码:
Imports System.Windows.Controls Partial MustInherit Class FooWindowBase : Inherits ChildWindow Public Sub New() InitializeComponent() End Sub … End Class
SomeFooWindow:
XAML:
<l:FooWindowBase x:Class="FooNamespace.SomeFooWindow" xmlns:l="clr-namespace:FooNamespace;assembly=Foo" …> … </l:FooWindowBase>
代码:
Partial Class SomeFooWindow : Inherits FooWindowBase Public Sub New() InitializeComponent() End Sub … End Class