Visual Studio 2013 and C # - unable to add event handler

I am working on a WPF project, and after I did everything in the Xaml file, I wanted to start doing in my CS file. Now I tried to add an event using this small bolt in the properties, but every time I click on any event (for example, I select a button in XAML and try to add β†’ MyButton_Click), I get a pop-up message β€œMUST ADD EVENT HANDLER”.

I hope you can help me.

+8
c # wpf xaml
source share
2 answers

yes, @ right, I also suffered from the same problem when I was new to WPF. Check your x: class in the XAML file, it should contain the namespace used in the code. for example. x: Class = "MainWindow" should be something like x: Class = "namespace.MainWindow" if it does not work, try restarting VS or trying to recreate the project with the correct name, hoping that it will solve your problem.

+20
source share

I suffered from the same problem as you. The error occurs when there is a strong any syntax error in your XAML file, such as misspell, missing tag, comma, missing method / event handler, or link difficulties.

It is for the same reason that you cannot add an event or change any property in the properties window, but without any messages or errors. Check your syntax carefully.

Sincerely.

+2
source share

All Articles