【发布时间】:2012-12-10 21:38:43
【问题描述】:
我已经创建了一个这样的基类:
`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);
}
}
}`
还有这个子类:
namespace XXX.Screens
{
public partial class Settings_screen_Child : Settings_screen_BASE
{
public Settings_screen_Child()
{
if (DEBUG)
Debug.WriteLine(this.GetType() + "->" + System.Reflection.MethodBase.GetCurrentMethod().Name);
base.InitializeComponent();
if (DEBUG)
Debug.WriteLine(this.GetType() + "<-" + System.Reflection.MethodBase.GetCurrentMethod().Name);
}
}
}
当我现在打电话时:
this.NavigationService.Navigate(new Uri("/Screens/Settings_screen_BASE.xaml", UriKind.Relative));
效果很好,
但是当我打电话时
this.NavigationService.Navigate(new Uri("/Screens/Settings_screen_Child.xaml", UriKind.Relative));
我只是黑屏,调试输出没有显示任何子类的创建。
你能告诉我我在这里缺少什么吗?
我原以为调用子类与调用基类完全一样。
至少它应该调用Settings_screen_Child()
【问题讨论】:
标签: c# windows-phone-7 inheritance