FerroUI/ docs

Search guides, controls, Rust APIs, and XAML.

    GitHub ↗

    CommandCanExecuteObserver

    struct · ferroui-xaml-interactivity · v0.5.0

    struct CommandCanExecuteObserver
    

    Observes an ICommand and reports whether it can execute with a specified parameter.

    Use this helper from custom command-backed behaviors to expose a bindable command state, such as a direct property. Call start when the behavior is attached, update when the command or command parameter changes, and stop when the behavior is detached.

    The command event subscription uses a weak reference to this observer so a long-lived command does not keep the observer or owning behavior alive if cleanup is missed.

    Deviation (DEVIATIONS.md, Behaviors): the reference posts the callback to the user-interface thread when a command raises its notification on another thread. Commands and observers of the port belong to the thread that created them (they are not Send), so the callback always runs on that thread.

    View source

    Members

    new

    fn new(set_can_execute: impl Fn(bool) -> () + 'static) -> Self
    

    Initializes a new instance of the CommandCanExecuteObserver class; set_can_execute receives the current command execution state.

    Source

    start

    fn start(self: &Self, command: Option<Rc<dyn ICommand>>, parameter: Option<BoxedValue>)
    

    Starts observing the specified command and reports its initial execution state; a null command reports that execution is allowed.

    Source

    start_with

    fn start_with(self: &Self, command: Option<Rc<dyn ICommand>>, parameter: Option<BoxedValue>, is_parameter_known: bool)
    

    Starts observing the specified command and reports its initial execution state.

    is_parameter_known is true when parameter is the actual parameter to evaluate, false when the parameter will only be available at execution time: the observer then reports true without calling can_execute, which avoids probing commands with placeholder values such as null when event arguments or picker results will provide the real parameter later.

    Source

    update

    fn update(self: &Self, command: Option<Rc<dyn ICommand>>, parameter: Option<BoxedValue>)
    

    Updates the observed command and command parameter. Has no effect until start has been called.

    Source

    update_with

    fn update_with(self: &Self, command: Option<Rc<dyn ICommand>>, parameter: Option<BoxedValue>, is_parameter_known: bool)
    

    Updates the observed command and command parameter; see start_with for is_parameter_known. Has no effect until start has been called.

    Source

    stop

    fn stop(self: &Self)
    

    Stops observing the current command and clears the stored command parameter.

    Source

    Trait implementations

    • Send
    • Sync
    • Freeze
    • UnsafeUnpin
    • Unpin
    • UnwindSafe
    • RefUnwindSafe
    • Borrow<T>
    • BorrowMut<T>
    • Into<U>
    • From<T>
    • TryInto<U>
    • TryFrom<U>
    • Any
    • ClassDefaults
    • ErasedDestructor
    • IntoEither
    • IDisposable

    Availability

    Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.