Reputation: 917
The funny thing is that it worked. The compiler had no issues with the code, although it is something that I've never seen (maybe because I'm a novice). I would like to use the newly inherited base Page/class as a place to store commonly used code so that I don't have to duplicate anything. Take a look here:
public sealed partial class HumanPage : SpeciesBasePage;
public sealed partial class AnimalPage : SpeciesBasePage;
public class SpeciesBasePage : Page;
Obviously, it works because SpeciesBasePage implements the Page class. So you will also see that the related XAML page will have a different base class as its opening tag:
<local:SpeciesBasePage
x:Class="PageInheritanceProject.HumanPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
...>
<Grid>
<TextBlock Text="Hello, world!" />
</Grid>
</local:SpeciesBasePage>
Is it okay to do this? Thanks!
Upvotes: 0
Views: 80
Reputation: 12276
That's a fairly standard inheritance chain. In c# terms. Two things to consider.
1)
Usage of Pages at all is the thing many commercial teams would question.
Many teams do not use pages at all and instead use usercontrols ( hosted in contentcontrols ).
2)
Inheriting from pages. You can't inherit xaml so why are you inheriting a UI control which is likely a container?
Upvotes: 1