Skip to main content

Module multi_binding

Module multi_binding 

Source
Expand description

MultiBinding + IMultiValueConverter from Rust.

A MultiBinding combines N child Bindings through a Rust MultiValueConverter into a single target value, the code-built equivalent of authoring a <MultiBinding> with several <Binding> children and a Converter in XAML. The converter receives the source values as an array of boxed arguments (one per child binding, in order) and returns a single combined value.

let conv = MultiConverter::new(|values: &[ConvertArg], _p: &ConvertArg| {
    let a = values.first().and_then(ConvertArg::as_str).unwrap_or_default();
    let b = values.get(1).and_then(ConvertArg::as_str).unwrap_or_default();
    Some(Converted::String(format!("{a} {b}")))
});
let mb = MultiBinding::new()
    .converter(&conv)
    .add_binding(Binding::new("First"))
    .add_binding(Binding::new("Last"));
mb.set_on(&label, "Text");

§Lifetime

Both MultiConverter and MultiBinding own a +1 reference released on drop. MultiBinding::set_on makes Noesis take its own reference, so the handle may be dropped after wiring; the converter stays alive while the binding references it. The converter’s handler box is freed exactly once, by the C++ destructor, after the last reference drops. Modelled on crate::converters::Converter.

§Threading

convert fires from inside Noesis’s binding pump on whatever thread drives the view. The handler is stored behind Send; keep the work small.

Re-exports§

pub use crate::binding::BindingMode;

Structs§

MultiBinding
A code-built Noesis::MultiBinding. Add child Bindings with add_binding, attach a MultiConverter with converter, then wire it onto a target DP with set_on.
MultiConverter
A Rust-backed IMultiValueConverter. Owns a +1 reference released on drop. Attach it to a MultiBinding with MultiBinding::converter.

Traits§

MultiValueConverter
Rust-side multi-value conversion logic: combine the source values of the child bindings into one target value. Returning None signals UnsetValue (the binding falls back to its FallbackValue / the property default).