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§
- Multi
Binding - A code-built
Noesis::MultiBinding. Add childBindings withadd_binding, attach aMultiConverterwithconverter, then wire it onto a target DP withset_on. - Multi
Converter - A Rust-backed
IMultiValueConverter. Owns a+1reference released on drop. Attach it to aMultiBindingwithMultiBinding::converter.
Traits§
- Multi
Value Converter - Rust-side multi-value conversion logic: combine the source values of the
child bindings into one target value. Returning
NonesignalsUnsetValue(the binding falls back to itsFallbackValue/ the property default).