subclassing PhoneApplicationPage is not calling the inherited methods

人盡茶涼 提交于 2020-01-06 08:34:05

问题


I have created a Base class like this:

`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);
        }
    }
}`

And this child class:

 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);
        }
    }
}

When I now call:

 this.NavigationService.Navigate(new Uri("/Screens/Settings_screen_BASE.xaml", UriKind.Relative));

It works well,

but when I call

  this.NavigationService.Navigate(new Uri("/Screens/Settings_screen_Child.xaml", UriKind.Relative));

I just get a black screen and the debug output does not show any creation of the child class.

Can you please tell me what I am missing here?

I would have expected that calling the child would do exactly the same as calling the base class. At least it should call Settings_screen_Child()


回答1:


Not sure what's going on. You should make sure that you are referencing the proper base class in the in the child page. I created my own version of your example, and it seems to be working fine for me. You can check out my sample project here : http://sdrv.ms/XLcyvR



来源:https://stackoverflow.com/questions/13809699/subclassing-phoneapplicationpage-is-not-calling-the-inherited-methods

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!