I
I
im_noob2021-04-07 13:14:25
WPF
im_noob, 2021-04-07 13:14:25

How to make a window close on button click?

Writing:

private void Exit_Click(object sender, RoutedEventArgs e)
        { 
            this.Close(); // ошибка
        }


Error: 'Menu' does not contain a 'Close' definition, and no accessible extension method 'Close' could be found that accepts the type 'Menu' as its first argument (possibly missing a using directive or an assembly reference).

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
twobomb, 2021-04-07
@im_noob

App.Current.MainWindow.Close();
PS Or Application instead of App, depending on your name

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question