Intersoft ClientUI Documentation
DelegateCommand Class

Defines a command that implements ICommand which passes CanExecute and Executed as delegated method. The DelegateCommand is commonly used in M-V-VM pattern application development.
Public Class DelegateCommand 
Dim instance As DelegateCommand
public class DelegateCommand 
public ref class DelegateCommand 
ClientUI is sophisticatedly engineered to address a number of challenges in building MVVM pattern applications that target both Silverlight and WPF platform.

ClientUI streamlines the application development using MVVM pattern with commanding pattern which has been extended to work in both platforms. One of the techniques used in ClientUI is by extending the commanding framework to support MVVM through built-in DelegateCommand class.

Built on the top of ClientUI commanding framework, the DelegateCommand enables you to define the commands and its logic in a ViewModel class and bind to them in the View through the Command property. Furthermore, the DelegateCommand takes advantage of the routed command concept in which the IsEnabled state of the command sources will be automatically synchronized depending on whether the command can execute.

This example shows how to create DelegateCommand in the ViewModel and bind it to the Command property of the UXToolBarButton in the View.

Copy Code
    <ViewModels:EditorViewModel x:Key="EditorViewModel"></ViewModels:EditorViewModel>
<Grid x:Name="LayoutRoot" DataContext="{StaticResource EditorViewModel}">
    <Intersoft:UXToolBar HorizontalAlignment="Left" Margin="10,10,0,0" Name="uXToolBar1" VerticalAlignment="Top">
            <Intersoft:UXToolBarButton Content="New" Command="{Binding NewAction}"/>
Copy Code
public class EditorViewModel : ViewModelBase
    public EditorViewModel()
        this.NewAction = new DelegateCommand(NewCommandAction, CanNewAction);

    public DelegateCommand NewAction { get; private set; }

    private bool CanNewAction(object parameter)
        //this method validate whether or not the New ToolBarButton is active
        //In this sample, I will keep the New ToolBarButton to be always active
        return true;

    private void NewCommandAction(object parameter)
        //this method will be triggered when the New ToolBarButton is clicked
        MessageBoxServiceProvider.Standalone = true;

        MessageBoxServiceProvider.Show("Execute New Action", "Information",


For a more complete version of this example, see How-to: Handle Tool Bar Command using MVVM Pattern.

To learn more about using MVVM pattern in ClientUI application development, see Walkthrough: Create Your First ClientUI Application using MVVM Pattern.
Inheritance Hierarchy



Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also


DelegateCommand Members
Intersoft.Client.Framework.Input Namespace


MVVM Pattern Overview

Send Feedback