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

DelegateCommand

Updated on Mar 10, 2026

The DelegateCommand class provides a simple ICommand implementation. It is located in the Telerik.UI.Xaml.Controls namespace and exposes the following methods and events:

  • CanExecute: Defines the method that determines whether the command can execute in its current state.
  • Execute: Defines the method to be called when the command is invoked.
  • CanExecuteChanged: Raised when changes occur that affect whether the command should execute.

The DelegateCommand constructor has two overloads. The first accepts just a Delegate to execute as a parameter. The second one accepts the Delegate to execute as well as a Predicate that determines if the delegate can be executed.

Example 1: DelegateCommand implementation in your ViewModel that accepts a delegate and a predicate

C#
	
    public class ViewModel
    {
        public ICommand MyCommand { get; set; }

        public ViewModel()
        {
            this.MyCommand = new DelegateCommand(OnMyCommandExecuted, OnMyCommandCanExecute);
        }

        private bool OnMyCommandCanExecute(object obj)
        {
            return true;
        }

        private void OnMyCommandExecuted(object obj)
        {
            MessageBox.Show("Custom Command Executed!");
        }
    }

Example 2: Using the command in xaml

XAML
	<Button Command="{Binding MyCommand}" Content="Execute command" />

See Also

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