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

ViewModelBase

Updated on Mar 10, 2026

The ViewModelBase abstract class is designed to serve as a base class for any view model that needs to raise the PropertyChanged event.

ViewModelBase implements the INotifyPropertyChanged interface. This means that you can directly inherit the class in your view models instead of implementing the interface for each model separately.

Example 1: Custom ViewModel that inherits ViewModelBase

C#
    using Telerik.Windows.Controls;
    public class MyViewModel : Telerik.Core.ViewModelBase
    {
        private MyItemInfo selectedItem;
		private ObservableCollection<MyItemInfo> items;
		
        public MyItemInfo SelectedItem
        {
            get { return this.selectedItem; }
            set
            {
                if (value != this.selectedItem)
                {
                    this.selectedItem = value;
                    this.OnPropertyChanged(() => this.SelectedItem);
                }
            }
        }
        
        public ObservableCollection<MyItemInfo> Items
        {
            get
            {
                return this.items;
            }
            set
            {
                this.items = value;
                this.OnPropertyChanged("Items");
            }
        }
    }

As shown in Example 1, when explicitly specifying the changed property, there are few overloads for the OnPropertyChanged method. The OnPropertyChanged method supports also the CallerMemberName attribute which means that you can call the method without providing the property's name.

Example 2: Using the OnPropertyChanged overload with the CallerMemberName attribute

C#
	public MyItemInfo SelectedItem
	{
		get { return this.selectedItem; }
		set
		{
			if (value != this.selectedItem)
			{
				this.selectedItem = value;
				this.OnPropertyChanged();
			}
		}
	}

See Also

In this article
See Also
Not finding the help you need?
Contact Support