Share via


BindableObject Class

Definition

Provides a mechanism to propagate data changes from one object to another. Enables validation, type coercion, and an event system.

public ref class BindableObject abstract : Microsoft::Maui::Controls::Internals::IDynamicResourceHandler, System::ComponentModel::INotifyPropertyChanged
public abstract class BindableObject : Microsoft.Maui.Controls.Internals.IDynamicResourceHandler, System.ComponentModel.INotifyPropertyChanged
type BindableObject = class
    interface INotifyPropertyChanged
    interface IDynamicResourceHandler
Public MustInherit Class BindableObject
Implements IDynamicResourceHandler, INotifyPropertyChanged
Inheritance
BindableObject
Derived
Implements

Remarks

The BindableObject class provides a data storage mechanism that enables the application developer to synchronize data between objects in response to changes, for example, between the View and View Model in the MVVM design pattern. All of the visual elements in the Microsoft.Maui.Controls namespace inherit from BindableObject class, so they can all be used to bind the data behind their user interface.

Constructors

BindableObject()

Initializes a new instance of the BindableObject class.

Fields

BindingContextProperty

Bindable property for BindingContext.

Properties

BindingContext

Gets or sets an object that contains the properties that will be targeted by the bound properties that belong to this BindableObject. This is a bindable property.

Dispatcher

Gets the dispatcher that was available when this bindable object was created, otherwise tries to find the nearest available dispatcher (probably the window's/app's).

Methods

ApplyBindings()

Applies all the current bindings to BindingContext.

ClearValue(BindableProperty)

Clears any value that is previously set for a bindable property.

ClearValue(BindablePropertyKey)

Clears any value that is previously set for a bindable property, identified by its key.

CoerceValue(BindableProperty)

Coerces the value of the specified bindable property. This is done by invoking BindableProperty.CoerceValueDelegate of the specified bindable property.

CoerceValue(BindablePropertyKey)

Coerces the value of the specified bindable property. This is done by invoking BindableProperty.CoerceValueDelegate of the specified bindable property.

GetValue(BindableProperty)

Returns the value that is contained in the given bindable property.

IsSet(BindableProperty)

Determines whether or not a bindable property exists and has a value set.

OnBindingContextChanged()

Raises the BindingContextChanged event.

OnPropertyChanged(String)

Raises the PropertyChanged event.

OnPropertyChanging(String)

Raises the PropertyChanging event.

RemoveBinding(BindableProperty)

Removes a previously set binding from a bindable property.

SetBinding(BindableProperty, BindingBase)

Assigns a binding to a bindable property.

SetInheritedBindingContext(BindableObject, Object)

Sets the inherited context to a nested element.

SetValue(BindableProperty, Object)

Sets the value of the specified bindable property.

SetValue(BindablePropertyKey, Object)

Sets the value of the specified bindable property.

UnapplyBindings()

Removes all current bindings from the current context.

Events

BindingContextChanged

Occurs when the value of the BindingContext property changes.

PropertyChanged

Occurs when a property value changes.

PropertyChanging

Occurs when a property value is changing.

Explicit Interface Implementations

IDynamicResourceHandler.SetDynamicResource(BindableProperty, String)

Extension Methods

GetPropertyIfSet<T>(BindableObject, BindableProperty, T)
SetAppTheme<T>(BindableObject, BindableProperty, T, T)
SetAppThemeColor(BindableObject, BindableProperty, Color, Color)
SetBinding(BindableObject, BindableProperty, String, BindingMode, IValueConverter, String)

Creates and applies a binding to a property.

SetBinding<TSource,TProperty>(BindableObject, BindableProperty, Func<TSource,TProperty>, BindingMode, IValueConverter, Object, String, Object, Object, Object)

Creates a binding between a property on the source object and a property on the target object.

Applies to