C# 子类化PhoneApplicationPage未调用继承的方法
我创建了一个基类,如下所示:C# 子类化PhoneApplicationPage未调用继承的方法,c#,windows-phone-7,inheritance,C#,Windows Phone 7,Inheritance,我创建了一个基类,如下所示: `namespace XXX.Screens { public partial class Settings_screen_BASE : PhoneApplicationPage { public static readonly bool DEBUG = true; public Settings_screen_BASE() { if (DEBUG)
`namespace XXX.Screens
{
public partial class Settings_screen_BASE : PhoneApplicationPage
{
public static readonly bool DEBUG = true;
public Settings_screen_BASE()
{
if (DEBUG)
Debug.WriteLine(this.GetType() + "->" + System.Reflection.MethodBase.GetCurrentMethod().Name);
InitializeComponent();
if (DEBUG)
Debug.WriteLine(this.GetType() + "<-" + System.Reflection.MethodBase.GetCurrentMethod().Name);
}
}
}`
它工作得很好
但是当我打电话的时候
this.NavigationService.Navigate(new Uri("/Screens/Settings_screen_Child.xaml", UriKind.Relative));
我只是得到一个黑屏,调试输出没有显示任何子类的创建
你能告诉我我在这里错过了什么吗
我本以为调用子类与调用基类完全一样。
至少它应该调用
Settings\u screen\u Child()。您应该确保在子页面的中引用了正确的基类。我创建了我自己版本的示例,它似乎对我很有效。您可以在这里查看我的示例项目:我所需要的绝对完美-非常感谢您的努力!
this.NavigationService.Navigate(new Uri("/Screens/Settings_screen_BASE.xaml", UriKind.Relative));
this.NavigationService.Navigate(new Uri("/Screens/Settings_screen_Child.xaml", UriKind.Relative));