i want to create a Window in an ControlLibrary called MyWindow so that i can define a Standard Look for all my new Applications (for example i want to put an Icon in the MyWindow) and some basic logic so i can inherit from that window in other Wpf-Applications.
But if i try to inherit MyWindow in another application i get an error …
Can somebody give me a hint how i can solve this problem?
i have tow projects:
1. my ControlLib where i define a Base Window
2. A Project where i want to use my Base as the main Window
My Base Window looks like the following:
<Window x:Class="BaseWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Icon="GeoAS.ico"
Title="BaseWindow" Height="300" Width="300"
Background="black">
<Grid>
</Grid>
</Window>
This in the Namespace MyControllLib.
I’ve added this Lib as a reference to my Project where i want to use this Window as my Main Window.
I expected to put somthing like this is my Codebehind from the new Window:
Class Window1
Inherits MyControlLib.BaseWindow
End Class
But the compiler put out an error (i have to translate, because the error is in german):
The Baseclass of the Window1-Class has not to be different from the myControlLib.BaseWindow-Baseclass.
I have no idea whats to do
Your BaseWindow class should be in pure code. Like this:
and your derive class can be either in pure code or in xaml and code both. In first case you need to do just this:
but in second case you need to drive your xaml also, like this: