[Expand]General Information
[Expand]WinForms Controls
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Collapse]WPF Controls
  Prerequisites
 [Expand]What's Installed
 [Expand]Common Concepts
 [Collapse]MVVM Framework
  [Collapse]ViewModels
    BindableBase
    ViewModelBase
    POCO ViewModels
    Interaction of ViewModels
    Passing data between ViewModels (ISupportParameter)
    ViewModel relationships (ISupportParentViewModel)
  [Expand]Commands
  [Expand]Behaviors
  [Expand]Services
  [Expand]DXBinding
  [Expand]MIF
   Converters
   ViewLocator
   Messenger
   Data Annotation Attributes
   LayoutTreeHelper
   Weak Event
 [Expand]Controls and Libraries
 [Expand]Scaffolding Wizard
 [Expand]Localization
  Redistribution and Deployment
  Get More Help
 [Expand]API Reference
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Reporting
[Expand]Report and Dashboard Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]CodeRush
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

BindableBase

The BindableBase class implements the INotifyPropertyChanged interface and provides capabilities for easy implementation of bindable properties with the GetProperty and SetProperty methods.

The first parameter of the GetProperty and SetProperty methods is a lamda-expression that returns the property used for identifying the target property name (property names are internally obtained with the BindableBase.GetPropertyName<T> static method).

Property values are stored in an internal Dictionary (the GetProperty method uses this dictionary to get a property value based on the property name, the SetProperty method stores a property value using the property name as a key). This approach simplifies code, and allows code checking during compilation and renaming properties with standard Visual Studio refactoring capabilities.

The SetProperty method returns True or False values that indicate whether or not a property has been successfully changed (if you set the same value to the property, the SetProperty method returns False and changing notifications are not sent). Some SetProperty method overloads also take a callback method as a parameter. This callback is invoked after the field has been changed.

If you need to manually raise the INotifyPropertyChanged.PropertyChanged event for a specific property, use the RaisePropertyChanged/RaisePropertiesChanged method.

In rare cases, application performance can deteriorate when a property is frequently updated (due to the calculation of property names from lambda-expressions and the accessing of properties from the Dictionary storage). To accommodate these scenarios, use storage variables for properties and calculate property names once from the static constructor using the BindableBase.GetPropertyName<T> method.

Is this topic helpful?​​​​​​​