# CreatesCommandBindingViaEvent

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-reactiveui/binding/command_binding/struct-createscommandbindingviaevent/

**struct** · [`ferroui-reactiveui`](/docs/0.5.0/api/ferroui-reactiveui/) · v0.5.0

```rust
struct CreatesCommandBindingViaEvent<C>
```

Binds a command to an event of a control of type `C` (`CreatesCommandBindingViaEvent`):
executed with the latest command parameter each time the event is raised, if the command can
execute with it.

The events are registered by name (`with_event`). Without an event name,
the command binds to the first of [`DEFAULT_COMMAND_EVENTS`](/docs/0.5.0/api/ferroui-reactiveui/binding/command_binding/constant-default_command_events/) that is registered, then to the
first registered event.

The affinity is `BindingAffinity::EXPLICIT` for a named event and
`BindingAffinity::DEFAULT_EVENT` for a default event, for a control of type `C` only.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI/binding/command_binding/creates_command_binding_via_event.rs#L70)

## Members

- [`new`](#function-new)
- [`with_event`](#function-with_event)
- [`with_event_subscription`](#function-with_event_subscription)

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

### new

```rust
fn new() -> Self
```

A binder with no event.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI/binding/command_binding/creates_command_binding_via_event.rs#L88)

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

### with_event

```rust
fn with_event<A: ?Sized + 'static>(self: Self, name: impl Into<String>, event: fn(&C) -> &Event<A>) -> Self
```

Registers the event named `name` that `event` reads from a control.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI/binding/command_binding/creates_command_binding_via_event.rs#L93)

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

### with_event_subscription

```rust
fn with_event_subscription(self: Self, name: impl Into<String>, subscription: ControlEventSubscription<C>) -> Self
```

Registers the event named `name` that `subscription` adds a handler to.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.ReactiveUI/binding/command_binding/creates_command_binding_via_event.rs#L99)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- `Borrow<T>`
- `BorrowMut<T>`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- `Any`
- `Debug`
- `Default`
- [`ICreatesCommandBinding`](/docs/0.5.0/api/ferroui-reactiveui/binding/interfaces/trait-icreatescommandbinding/)

## Availability

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