Click or drag to resize

DelegateCommand Constructor

Initializes a new instance of the DelegateCommand class.

No callback is initially set, so they must be set via the property setters. This usage generates easy readable code even if the delegates are inlined.


Namespace: TomsToolbox.Wpf
Assembly: TomsToolbox.Wpf (in TomsToolbox.Wpf.dll) Version: 2.21.0+44d18b541fc9419ec3c549350a832394661b2a4d
XMLNS for XAML: Not mapped to an xmlns.
Syntax
public DelegateCommand()
Example
C#
public ICommand DeleteCommand
{
    get
    {
        return new DelegateCommand
        {
            CanExecuteCallback = delegate
            {
                return IsSomethingSelected();
            },
            ExecuteCallback = delegate
            {
                if (IsSomehingSelected())
                {
                    DelteTheSelection();
                }
            }
        };
    }
}
See Also