FerroUI/ docs

Search guides, controls, Rust APIs, and XAML.

    GitHub ↗

    ViewModelBase

    struct · ferroui-diagnostics · v0.5.0

    struct ViewModelBase
    

    The base of the view models of the developer tools: the property change notification and the helpers that raise it.

    A view model embeds it (the base class of the original) and forwards INotifyPropertyChanged to it. The name of the property is passed explicitly where the original takes the name of the calling member.

    The original also records every addition and removal of a handler in a list that nothing reads; the port leaves that list out.

    View source

    Members

    new

    fn new() -> Self
    

    Source

    set_on_property_changed

    fn set_on_property_changed(self: &Self, handler: Option<Rc<dyn Fn(&str) -> ()>>)
    

    The override of protected virtual void OnPropertyChanged(PropertyChangedEventArgs e) of a deriving view model: called with the name of the property before the handlers of property_changed. The base implementation does nothing. A deriving view model sets it once, when it is constructed (a closure over a weak reference to itself).

    Source

    raise_and_set_if_changed

    fn raise_and_set_if_changed<T: PartialEq>(self: &Self, field: &RefCell<T>, value: T, property_name: &str) -> bool
    

    RaiseAndSetIfChanged(ref field, value) for a field of a type that is not Copy: stores value and raises the notification of property_name when it differs from the stored value. Returns whether it did.

    Source

    raise_and_set_if_changed_cell

    fn raise_and_set_if_changed_cell<T: PartialEq + Copy>(self: &Self, field: &Cell<T>, value: T, property_name: &str) -> bool
    

    RaiseAndSetIfChanged(ref field, value) for a Copy field.

    Source

    raise_property_changed

    fn raise_property_changed(self: &Self, property_name: &str)
    

    RaisePropertyChanged(propertyName): the override of OnPropertyChanged, then the handlers.

    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
    • Default
    • INotifyPropertyChanged

    Availability

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