# XBinding

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-markup-xaml/markup_extensions/struct-xbinding/

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

```rust
struct XBinding
```

The binding of one target property to an `{x:Bind}` path: the compiled path, read from the
root source of the [`XBindings`](/docs/0.5.0/api/ferroui-markup-xaml/markup_extensions/struct-xbindings/) it belongs to, in the mode the markup gave it.

Its expression is the ordinary binding expression of the engine over the nodes of the path,
after a root node that publishes the root source only while the bindings are initialized.
`OneWay` and `TwoWay` follow change notification (registered properties,
`INotifyPropertyChanged`); `OneTime` reads when the bindings are initialized or updated.

The converter, the fallback value and the target null value of the markup are the options of
the expression (WinUI's `BindAssignment`, `GetConverterExpression`, `FallbackValueExpression`,
`TargetNullValueExpression`): the value of the path goes through `Convert` (and `ConvertBack`
when a `TwoWay` binding writes the target back), a path that cannot be read gives the target
the fallback value, a null value the target null value.

On an event (step X4) the path ends with the method the event calls; the compiler gives the
binding to `bind_routed_event` or
`bind_markup_event` instead of binding a property. The handler is
subscribed while the bindings of the root are initialized, and it calls the method on the
value of the path before it, read when the event is raised.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Markup/FerroUI.Markup.Xaml/markup_extensions/x_bind/binding.rs#L62)

## Members

- [`bindings`](#function-bindings)
- [`path`](#function-path)
- [`mode`](#function-mode)
- [`update_source_trigger`](#function-update_source_trigger)
- [`phase`](#function-phase)
- [`bind_routed_event`](#function-bind_routed_event)
- [`bind_markup_event`](#function-bind_markup_event)
- [`try_create_instance`](#function-try_create_instance)

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

### bindings

```rust
fn bindings(self: &Self) -> &Rc<XBindings>
```

The bindings of the root this binding reads from.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Markup/FerroUI.Markup.Xaml/markup_extensions/x_bind/binding.rs#L85)

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

### path

```rust
fn path(self: &Self) -> Option<CompiledBindingPath>
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Markup/FerroUI.Markup.Xaml/markup_extensions/x_bind/binding.rs#L89)

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

### mode

```rust
fn mode(self: &Self) -> BindingMode
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Markup/FerroUI.Markup.Xaml/markup_extensions/x_bind/binding.rs#L93)

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

### update_source_trigger

```rust
fn update_source_trigger(self: &Self) -> UpdateSourceTrigger
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Markup/FerroUI.Markup.Xaml/markup_extensions/x_bind/binding.rs#L97)

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

### phase

```rust
fn phase(self: &Self) -> i32
```

The phase in which a container reads the binding (`x:Phase` of the element of its
target); `0` without one.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Markup/FerroUI.Markup.Xaml/markup_extensions/x_bind/binding.rs#L103)

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

### bind_routed_event

```rust
fn bind_routed_event(self: &Self, target: &Ref<Interactive>, event: &RoutedEvent) -> Result<(), XamlLoadError>
```

`target.Event += handler` of a routed event (`Click="{x:Bind OnClick}"`): the handler is
added with the routes of a handler markup adds (direct and bubble, unhandled events) when
the bindings of the root are initialized, and removed when they stop tracking. The target
is held weakly.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Markup/FerroUI.Markup.Xaml/markup_extensions/x_bind/binding.rs#L127)

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

### bind_markup_event

```rust
fn bind_markup_event(self: &Self, event: &'static MarkupEvent, target: MarkupValue) -> Result<(), XamlLoadError>
```

`target.Event += handler` of an event that is not a routed event, which metadata
declares with its subscription (`events:`): subscribed when the bindings of the root
are initialized; the subscription the event returns is released when they stop tracking
(an event without one keeps the handler, which then does nothing). The target is held
weakly.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Markup/FerroUI.Markup.Xaml/markup_extensions/x_bind/binding.rs#L149)

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

### try_create_instance

```rust
fn try_create_instance(self: &Self, target: &FerroObject, target_property: Option<&'static FerroProperty>) -> Result<Rc<BindingExpression>, XamlLoadError>
```

The expression of the binding on `target_property` of `target`, registered with the
bindings of its root.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/Markup/FerroUI.Markup.Xaml/markup_extensions/x_bind/binding.rs#L185)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- `Borrow<T>`
- `BorrowMut<T>`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- `Any`
- [`AnyValue`](/docs/0.5.0/api/ferroui-base/trait-anyvalue/)
- [`ClassDefaults`](/docs/0.5.0/api/ferroui-base/trait-classdefaults/)
- `ErasedDestructor`
- `IntoEither`
- [`BindingBase`](/docs/0.5.0/api/ferroui-base/data/trait-bindingbase/)
- `PartialEq`
- [`MarkupTyped`](/docs/0.5.0/api/ferroui-base/metadata/trait-markuptyped/)

## Availability

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