Is it possible to extend the "Page"-class in C#'s WPF-toolkit (or, respectively, any other WPF-class)? What i tried to do:
public class ExtendedPage : Page{
protected void doStuff(){
// lots of joy n pleasure
}
}
public partial class RandomWindow : ExtendedPage{
private void randomMethod(){
doStuff(); // causes error
}
}
The reason I'm asking is pretty obvious: After extending the Page-class (ExtendedPage), the subclass (RandomWindow) has no acces to the methods of its base. This (at least it's my guess) caused by the circumstance of RandomWindow being partial. Since this class unfortunately is generated by WPF (links to the corresponding *.xaml), I'm unable to locate the other part of the partial-class.
This question might lead to a pretty obvious answer that makes me look like a total moron, but apprently I'm unable to figure it out. I might add that I've just started working with C#, my programming origin is Java.
The exact error-message is "Partial declarations of 'type' must not specify different base classes" (CS0263).
As response to one of the comments: The declaration of "Page" in the *.xaml seems to generate an code-behind-file whose base-class is "Page" (and not ExtendedPage). Changing this seems not to work either, the compiler complains about the type ExtendedPage not being found.
<Page x:Class="...RandomWindow" ... />
// to
<src:ExtendedPage x:class="...RandomWindow"
xlmns:src="...ExtendedPage" />
Partial declarations of 'type' must not specify different base classes
Well, that one's a no-brainer, you probably have a XAML somewhere which looks like this:
<Page x:Class="MyApp.MyNamespace.RandomWindow" ....>
Implicitly specifying a Page
as the base, you need however:
<local:ExtendedPage x:Class="MyApp.MyNamespace.RandomWindow"
xmlns:local="clr-namespace:MyApp.NSContainingExtendedPage"
...>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With