Class
ViewModelBase

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:

cs-api-definition
public abstract class ViewModelBase : INotifyPropertyChanged, IDisposable

Inheritance: objectViewModelBase

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

Implements: IDisposableINotifyPropertyChanged

Constructors

ViewModelBase()

Initializes a new instance of the ViewModelBase class.

Declaration

cs-api-definition
protected ViewModelBase()

Methods

Dispose()

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

Declaration

cs-api-definition
public void Dispose()

Implements IDisposable.Dispose()

Dispose(bool)

Releases unmanaged and - optionally - managed resources.

Declaration

cs-api-definition
protected virtual void Dispose(bool disposing)

Parameters

disposing

bool

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

InvokeOnUIThread(Action)

Invokes the specified action on the UI thread.

Declaration

cs-api-definition
public static void InvokeOnUIThread(Action action)

Parameters

action

Action

An Action to be invoked on the UI thread.

OnPropertyChanged(string)

Raises this object's PropertyChanged event.

Declaration

cs-api-definition
protected virtual void OnPropertyChanged(string propertyName)

Parameters

propertyName

string

The property that has a new value.

OnPropertyChanged<T>(Expression<Func<T>>)

Raises this object's PropertyChanged event.

Declaration

cs-api-definition
protected virtual void OnPropertyChanged<T>(Expression<Func<T>> propertyExpression)

Parameters

propertyExpression

Expression<Func<T>>

A MemberExpression, containing the property that value changed.

Remarks

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

RaisePropertyChanged(string)

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

Declaration

cs-api-definition
protected void RaisePropertyChanged(string propertyName = null)

Parameters

propertyName

string

The property that has a new value.

UpdateValue<T>(ref T, T, string)

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

Declaration

cs-api-definition
protected bool UpdateValue<T>(ref T field, T value, string propertyName = null)

Parameters

field

T

A reference to the field to update.

value

T

The new value for the field.

propertyName

string

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.

VerifyPropertyName(string)

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.

Declaration

cs-api-definition
[Conditional("DEBUG")]
protected void VerifyPropertyName(string propertyName)

Parameters

propertyName

string

Events

PropertyChanged

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

Declaration

cs-api-definition
public event PropertyChangedEventHandler PropertyChanged

Event Value

PropertyChangedEventHandler

Implements INotifyPropertyChanged.PropertyChanged