1

Here's my NewWin Class inherited from Window (System.Windows.Window) Class.

public partial class NewWin : Window
{
    public NewWin()
    {
        this.Background = new SolidColorBrush(Color.FromRgb(0, 0, 0));
    }
}

And my MainWindow (WPF's Default) inherited from NewWin instead of Window.

public partial class MainWindow : NewWin
{
    public MainWindow()
    {
        InitializeComponent();
    }
}

Upon compilation there is an error message writing as followed:

Partial declarations of 'Test.MainWindow' must not specify different base classes

With 'Test' being the name of my project.

1 Answer 1

7

Go to MainWindow.xaml and change type of root element from Window to NewWin.

Sign up to request clarification or add additional context in comments.

1 Comment

I probably must have added that I'm not an expert on xaml, so by root I assumed that you meant x:Class="Test.MainWindow" which was changed to x:Class="Test.NewWin", and that solved the problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.