I have the following hierarchy of classes:
abstract MyWindowBase : System.Windows.Window (i.e. the WPF one)
MyWindow : MyWindowBase
I want to create a Window of type MyWindow as a root element in XAML. I found only this way of doing it:
<local:MyWindowBase
x:Class="MyWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
local:x="clr-namespace:MyProjectNamespace">
<local:MyWindowBase.Resources>...</local:MyWindowBase.Resources>
...
</local:MyWindowBase>
I.e. I’m specifing my abstract type as the root element, which seems awkward.
I also tried the obvious way:
<Window
x:Class="MyWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
...
</Window>
and defining MyWindow : MyWindowBase in code-behind, but it clashes with the class definition in the generated file which says MyWindow : Window.
Is there a better way?
Thanks
Check this recent post of mine which explains exactly this sort of thing – how to derive one page from another (the methodology is exactly the same).