Event attributes need an event handler defined in a C# file. This video looks at the automatically added event handlers and verifies that they match the correct event signature. Next is a look at how to use the sender parameter to determine what UI element raised the event. Finally you’ll see how to use the special EventArgs parameter available in each event handler.
- [Instructor] I've added my event attributes to my XAML,…and I'm ready to add some code in my C#.…Before I do that, I would like to review a couple of items.…One, remember that there are two buttons,…on line 22 and line 23,…that both have the same click handler.…They both point to Button_Click.…The second thing is…remember that every time I added an event attribute,…Visual Studios wrote a name for me.…It suggested creating a new event handler,…and it wrote the name.…At the same time, over in the C# code,…it created the method.…
The nice thing that it did…is it used the name that it suggested,…and it used the correct signature.…So the MouseMove event is raising the event,…and it's going to pass two arguments over here.…Visual Studio created a method with those two arguments.…This first item represents the item that raised the event.…The second one is event-specific information.…In this case, the mouse event…is going to hand me a bunch of data…bundled inside this MouseEventArgs class,…and then I can look through it…
- What is XAML?
- What frameworks use XAML?
- Working with XAML and Visual Studio
- Exploring XAML namespaces
- Instantiating objects
- Subscribing to events
- Using XAML in Windows Presentation Foundations, Universal Windows, and more