# IAddEventHandler

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-xaml-interactivity/trait-iaddeventhandler/

**trait** · [`ferroui-xaml-interactivity`](/docs/0.5.0/api/ferroui-xaml-interactivity/) · v0.5.0

```rust
trait IAddEventHandler
```

A service that provides a way to register event handlers for specific events on various
controls.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Behaviors/FerroUI.Xaml.Interactivity/events/contract/i_add_event_handler.rs#L13)

## Members

- [`matches`](#function-matches)
- [`add_handler`](#function-add_handler)

<a id="function-matches"></a>

### matches

```rust
fn matches(self: &Self, source: &BoxedValue, event_name: &str) -> bool
```

Checks if the given source object and event name match the criteria for this event
handler.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Behaviors/FerroUI.Xaml.Interactivity/events/contract/i_add_event_handler.rs#L16)

<a id="function-add_handler"></a>

### add_handler

```rust
fn add_handler(self: &Self, source: &BoxedValue, event_name: &str, handler: AddEventHandlerCallback) -> Option<Rc<dyn IDisposable>>
```

Registers an event handler for a specific event on the given source object. Disposing the
returned handle removes it; `None` when the source or the event does not match.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Behaviors/FerroUI.Xaml.Interactivity/events/contract/i_add_event_handler.rs#L20)

## Trait implementations

- [`IAddEventHandler`](/docs/0.5.0/api/ferroui-xaml-interactivity/trait-iaddeventhandler/)

## Availability

Extracted for `aarch64-apple-darwin`. Cargo features are listed in the [crate index](/docs/0.5.0/api/).
