Reputation: 4959
I have a BaseDiagramPage
class which inherits directly from Page
. The idea is that it will hold common functionality across multiple pages (let me know if this is a bad way to do it). But my XAML
classes implementing BaseDiagramPage
are complaining that this.Loaded
does not exist. It works fine if I inherit from Page
directly in the XAML
class.
The BaseDiagramPage
class can literally have nothing in it.
Any insights would be appreciated.
public sealed partial class EmptyPage : BaseDiagramPage
{
public EmptyPage()
{
this.InitializeComponent();
// this property does not exist, BaseDiagramPage is public
this.Loaded += (sender, e) =>
{
// load something
};
}
}
EDIT:
BaseDiagramPage source
namespace CoreProject.Pages
{
public class BaseDiagramPage : Page
{
}
}
EDIT EDIT:
Using base.Loaded
works, but is that right? I want to call my classes Loaded
base.Loaded += (sender, e) =>
{
};
Upvotes: 0
Views: 46
Reputation: 39006
I think you forgot to change the XAML part of your EmptyPage
, so just change
<Page x:Class="xxx.EmptyPage" ...>
...
</Page>
to
<local:BaseDiagramPage x:Class="xxx.EmptyPage" ...>
...
</local:BaseDiagramPage>
After doing this, you can even remove the inheritance from your C# code as it's now redundant. So the following would just work.
public sealed partial class EmptyPage
Upvotes: 1