From the course: Microsoft XAML: 1 Core Concepts

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

Use event attributes to subscribe to events

Use event attributes to subscribe to events

From the course: Microsoft XAML: 1 Core Concepts

Start my 1-month free trial

Use event attributes to subscribe to events

- [Narrator] In this video, I'll look at the other type of attribute available for an object element. I'm referring to the EventAttribute. It lets you indicate what Event Handler is assigned to an Event. Or, to say it another way, what C Sharp code will run when an Event is raised. Here is the 30 second overview of .NET Events. A .NET type can define an Event. Other .NET objects can subscribe to the Event by creating a .NET method with the correct signature and indicating to .NET that they are a subscriber. This method is called an Event Handler. When the Event is raised, .NET calls all of the registered Event Handlers. Each Event defines a specific set of parameters. The Event Handler must exactly match that parameter list. This is how information is passed from the Event Publisher to the Event Subscriber. What we are doing with Zamil EventAttributes is subscribing to an Event and indicating the name of the C Sharp Event Handler. To demonstrate this, I'll use this UI. Consists of a…

Contents