When editing XAML file in VS 2019, generating event handler with "New Event Handler" options works for the first time, then it shows "Ensure Event Failed" after that. I need to close and reopen the xaml as the workaround.
The options should work without "Ensure Event Failed" error.
Nuget Package:
Package Version(s): 1.45.0
Affected platform(s):
Visual Studio
Relevant plugins
Howdy @riandika-lumaris, this sounds like a bug in visual studio for windows. Can you please reproduce the problem and use the menus within Visual Studio to report it to Microsoft?

ps. Out of interest are you using a shared project?
I don't think it is a bug from VS because the option works perfectly with pure UWP Solution.
And yes, there is a shared project because I use the uno extension to create the solution.
The "New Event Handler" functionality comes from VSWIN, I've got a hunch that you'd be able to reproduce this with a pure UWP solution that uses shared projects. So many things are changing under the hood of VSWIN at the moment. Typically, I'm raising 1 to 3 new feedback items every week. Uno has a meta ticket open at https://github.com/unoplatform/uno/issues/982, when you raise your feedback item can you please comment on it? Cheers.
Howdy @riandika-lumaris. I experienced this today and can confirm that it isn't a problem with Uno, it's a defect in vswin and shared projects. "Ensure Event Failed" appears when generating a new event handler on UWP when using Shared Projects. It does not happen when using a UWP class library.
Have opened https://developercommunity.visualstudio.com/content/problem/690015/uwp-ensure-event-failed-when-creating-new-event-ha.html. Could you drop on by and give it a 馃憤? Cheers.
Developer Community for Visual Studio Product family
is there any way to add event to controls from xaml?
@realivanjx it depends on the version of visual studio, but recent ones, (e.g. VS 16.5 preview) seems to improve the situation.
It still exist in vs2019 16.5
@jeromelaban This issue still exists in VS 2019 16.6. This is an incredibly annoying bug, and the issue over on Developer Community was closed just over a year ago with no solution or workaround.
I started working with UNO today and ran into the same problem. Is there a workaround or do I need to write the handlers manually?
@ElyasMTarek for now, no. There isn't a fix for this, though you can use the {x:Bind} event syntax for easier method authoring. See this document for details on how to use it.
@jeromelaban Thanks for the advice. Hope this will get fixed in near future tho.
I have the same problem, any updates to this?
Most helpful comment
Howdy @riandika-lumaris. I experienced this today and can confirm that it isn't a problem with Uno, it's a defect in vswin and shared projects. "Ensure Event Failed" appears when generating a new event handler on UWP when using Shared Projects. It does not happen when using a UWP class library.
Have opened https://developercommunity.visualstudio.com/content/problem/690015/uwp-ensure-event-failed-when-creating-new-event-ha.html. Could you drop on by and give it a 馃憤? Cheers.