pub struct ViewModelBase { /* private fields */ }Expand description
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.
Implementations§
Source§impl ViewModelBase
impl ViewModelBase
pub fn new() -> Self
Sourcepub fn set_on_property_changed(&self, handler: Option<Rc<dyn Fn(&str)>>)
pub fn set_on_property_changed(&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).
Sourcepub fn raise_and_set_if_changed<T: PartialEq>(
&self,
field: &RefCell<T>,
value: T,
property_name: &str,
) -> bool
pub fn raise_and_set_if_changed<T: PartialEq>( &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.
Sourcepub fn raise_and_set_if_changed_cell<T: PartialEq + Copy>(
&self,
field: &Cell<T>,
value: T,
property_name: &str,
) -> bool
pub fn raise_and_set_if_changed_cell<T: PartialEq + Copy>( &self, field: &Cell<T>, value: T, property_name: &str, ) -> bool
RaiseAndSetIfChanged(ref field, value) for a Copy field.
Sourcepub fn raise_property_changed(&self, property_name: &str)
pub fn raise_property_changed(&self, property_name: &str)
RaisePropertyChanged(propertyName): the override of
OnPropertyChanged, then the handlers.
Trait Implementations§
Source§impl Default for ViewModelBase
impl Default for ViewModelBase
Source§impl INotifyPropertyChanged for ViewModelBase
impl INotifyPropertyChanged for ViewModelBase
Source§fn property_changed(&self) -> &Event<str>
fn property_changed(&self) -> &Event<str>
Source§fn as_notify_property_changing(&self) -> Option<&dyn INotifyPropertyChanging>
fn as_notify_property_changing(&self) -> Option<&dyn INotifyPropertyChanging>
INotifyPropertyChanging, when it also raises the event of a property
that is about to change; None by default. Read moreAuto Trait Implementations§
impl !Freeze for ViewModelBase
impl !RefUnwindSafe for ViewModelBase
impl !Send for ViewModelBase
impl !Sync for ViewModelBase
impl !UnwindSafe for ViewModelBase
impl Unpin for ViewModelBase
impl UnsafeUnpin for ViewModelBase
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> ClassDefaults for Twhere
T: ?Sized,
impl<T> ClassDefaults for Twhere
T: ?Sized,
Source§fn static_constructor()
fn static_constructor()
affects_render, metadata
overrides). Read more