New to Telerik UI for WPFStart a free 30-day trial

Base class for all ViewModel classes. It provides support for property change notifications and has a DisplayName property. This class is abstract.

Definition

Namespace:Telerik.Windows.Controls

Assembly:Telerik.Windows.Controls.dll

Syntax:

C#
public abstract class ViewModelBase : INotifyPropertyChanged, IDisposable

Inheritance: objectViewModelBase

Derived Classes: CategoryUnifiedColorViewModelColorViewModelAIPromptCommandBaseAIPromptOutputItemModelAuthorMessageListItemViewModelBasePromptInputAttachedFilePromptInputButtonActionResponseActionSuggestedActionDistinctValueViewModelFilterDescriptorViewModelFilteringViewModelCompositeFilterViewModelFilterViewModelSimpleFilterViewModelFilterPartViewModelFormViewModelPagerControlsVisibilityModelFlagEnumEditorViewModelPropertySetViewModelGalleryGalleryItemLabelContainer.LabelContainerDataContextProxyGraphSourceBase<TNode, TLink>ItemViewModelBaseNavigatorItemViewModelNavigatorViewModelEditableObjectBase<T>ExpressionEditorViewModelDialogViewModelPivotItemsFilteringControlViewModelFieldListViewModelFieldPayloadDropIndicationDetailsFileBrowserGridViewSelectedItemsBindingBehaviorFileSystemInfoWrapperLayoutConfigurationModelAISummarizationTabItemViewModelAISummaryModelBookmarkItemViewModelMessageModelRadPdfViewerNavigationPaneViewModelTabItemViewModelBaseDistinctValueViewModelFieldFilterControlViewModelFilterDescriptorViewModelFilterOperatorViewModelFilteringViewModelGroupDistinctValueViewModelGroupViewModelSearchViewModelOfficeNavigationBarDialogViewModelOperatorValueFilterViewModelCheckBoxSectionViewModelDateFormatViewModelDatePickerSectionViewModelDropDownListsSectionViewModelGeneralSectionViewModelListItemViewModelPlainTextSectionViewModelRepeatingSectionViewModelSectionColumnDataViewModelGradientsGalleryItemShapesGalleryItemShapesOutlineDashTypeViewModelShapesOutlineWeightViewModelGradientDirectionGalleryItemPresetGradientGalleryItemDateSpanRecurrencePatternSchedulerDialogViewModelSplashScreenDataContextChartControlViewModelChartTypeViewModelMarkerInfoOutlineInfoSeriesViewModelCommentControlViewModelCommentEntryViewModelNoteControlViewModelStyleGalleryContentItemViewModelHeaderFooterTemplateCategoryModelTaskBoardCardModelPeriodSpanTimeMarkerTimeRulerViewModelDistinctValueViewModelFilterDescriptorViewModelFilteringViewModelBaseKeyViewModelDragVisualDataContext...

Implements: IDisposableINotifyPropertyChanged

Constructors

Initializes a new instance of the ViewModelBase class.

C#
protected ViewModelBase()

Methods

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

C#
public void Dispose()

Implements: IDisposable.Dispose()

Releases unmanaged and - optionally - managed resources.

C#
protected virtual void Dispose(bool disposing)
Parameters:disposingbool

true to release both managed and unmanaged resources. false to release only unmanaged resources.

Invokes the specified action on the UI thread.

C#
public static void InvokeOnUIThread(Action action)
Parameters:actionAction

An Action to be invoked on the UI thread.

Raises this object's PropertyChanged event.

C#
protected virtual void OnPropertyChanged(string propertyName)
Parameters:propertyNamestring

The property that has a new value.

Raises this object's PropertyChanged event.

C#
protected virtual void OnPropertyChanged<T>(Expression<Func<T>> propertyExpression)
Parameters:propertyExpressionExpression<Func<T>>

A MemberExpression, containing the property that value changed.

Remarks:

Use the following syntax: this.OnPropertyChanged(() => this.MyProperty); instead of: this.OnPropertyChanged("MyProperty");.

Raises this object's PropertyChanged event. This method uses CallerMemberName attribute to identify the source property when called without parameter.

C#
protected void RaisePropertyChanged(string propertyName = null)
Parameters:propertyNamestring

The property that has a new value.

Updates a field's value and raises the PropertyChanged event if the value has changed.

C#
protected bool UpdateValue<T>(ref T field, T value, string propertyName = null)
Parameters:fieldT

A reference to the field to update.

valueT

The new value for the field.

propertyNamestring

The name of the property that is changing. If null, the caller member name is used.

Returns:

bool

true if the value was changed, false otherwise.

Warns the developer if this object does not have a public property with the specified name. This method does not exist in a Release build.

C#
[Conditional("DEBUG")]
protected void VerifyPropertyName(string propertyName)
Parameters:propertyNamestring

Events

Raised when a property on this object has a new value.

C#
public event PropertyChangedEventHandler PropertyChanged

Implements: INotifyPropertyChanged.PropertyChanged