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.
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.
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