New to Telerik UI for WPF? Download free 30-day trial

XamlParseException When Using EventToCommandBehavior with the IsEnabledChanged Event


Product Version
Telerik UI for WPF 2023.3.1114


ArgumentException (often wrapped in XamlParseException) is thrown when using the EventToCommandBehavior with the IsEnabledChanged event.

The exception messages are:

  • XamlParseException: "Add value to collection of type 'Telerik.Windows.Controls.EventBindingCollection' threw an exception."

  • ArgumentException: "Cannot bind to the target method because its signature is not compatible with that of the delegate type."


This happens because the EventToCommandBehavior supports only events with arguments deriving from the EventArgs class. IsEnabledChanged along with few more UIElement events are using the DependencyPropertyChangedEventHandler delegate which works with the DependencyPropertyChangedEventArgs struct. This type of arguments doesn't derive from EventArgs.

To resolve the error, you can avoid using the EventToCommandBehavior and execute the command in code-behind. Or you can data bind the IsEnabled property of the corresponding element to a property in the view model, and then execute the command's logic in the property setter.

<telerik:RadListBox IsEnabled="{Binding IsEnabled, Modet=TwoWay}" /> 

private bool isEnabled;  
public bool IsEnabled 
    get { return isEnabled; } 
        isEnabled = value; 
        // execute command logic here 
In this article