I have a base class (WPF window) the design (xaml) and code.
I would like to inherit this class, not in order to modify the design of this window, but only to modify the code.
For example, I have a log-in window which is my base class, it has a textbox for username, textbox for password and log-in button.
In addition it has the code that handles the login.
Now, I want to implement 2 base classes of this dialog:
Authenticate against table X.
Authenticate against table Y.
I thought that I can design my base dialog as follows:
... BaseLoginWnd : Window
{
...
void Login_Click(...) // This method is implemented as a Template Method (Design pattern)
{
...
if (Authenticate())
{
MessageBox.Show("Success");
}
else
{
MessageBox.Show("Failure");
}
...
}
abstract bool Authenticate();
}
I'll mention that I know that this is not the best design for this particular example (It is better to create a separate class that performs the login), but this is just an example.
So my question is - How can I inherit from a window, using the base-class' design?