Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Inherited Window can not have a name?

I'm having trouble with naming my Window which is inherited from its Base Window, when I try to give a name to my Window I get following error.

The type BaseWindow cannot have a Name attribute. Values types and types without a default constructor can be used as items within ResourceDictionary.

XAML :

<log:BaseWindow 
   x:Class="EtraabMessenger.MainWindow"
   x:Name="main"
   xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
   xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
   xmlns:log="clr-namespace:EtraabMessenger.MVVM.View.Controls" 
   xmlns:VMCore="clr-namespace:EtraabMessenger.MVVM.VMCore" 
   VMCore:WindowClosingBehavior.Closing="{Binding DoCloseMainWindowCommand}"
   Height="464" Width="279">

</log:BaseWindow>

EDIT : Here is my BaseWindow class

public abstract class BaseWindow : Window, INotifyPropertyChanged
{
    protected BaseWindow()
    {
        // Note (Important) : This message should register on all windows
        // TODO : I'm planning to move this registeration to BaseWindow class
        Messenger.Register<bool>(GeneralToken.ClientDisconnected, DisconnectFromServer);
    }

    protected abstract void DisconnectFromServer(bool isDisconnected);
    protected abstract void RegisterTokens();
    protected abstract void UnRegisterTokens();

    ....
    ....
    ....

}

Any advice will be helpful.

like image 787
saber Avatar asked Jul 10 '12 18:07

saber


1 Answers

Your base window apparently, as the error states, needs a public default contructor (one without arguments), it also may not be abstract because an instance of it needs to be created.

like image 123
H.B. Avatar answered Nov 02 '22 00:11

H.B.