I have just upgraded my application (WPF) to drop 10 from the CTP and i am having problems with the DelegateCommand class.
public DelegateCommand(Action<T> executeMethod, Func<T, bool> canExecuteMethod)
: base((o) => executeMethod((T)o), (o) => canExecuteMethod((T)o))
if (executeMethod == null || canExecuteMethod == null)
throw new ArgumentNullException("executeMethod", Resources.DelegateCommandDelegatesCannotBeNull);
Type genericType = typeof(T);
// DelegateCommand allows object or Nullable<>.
// note: Nullable<> is a struct so we cannot use a class constraint.
if ((!genericType.IsGenericType) || (!typeof(Nullable<>).IsAssignableFrom(genericType.GetGenericTypeDefinition())))
throw new InvalidCastException(Resources.DelegateCommandInvalidGenericPayloadType);
When I associate the action with the DelegateCommand and this action has a parameter of type Boolean, DateTime, Int32, etc., then the InvalidCastException is raised.
ShowCalendarCommand = new DelegateCommand<DateTime>(ShowCalendarAction);
private void ShowCalendarAction(DateTime date)
My whole code is full of this kind of Actions (with this type of parameters) and all worked fine until the upgrade, but now i can't continue developing due to this issue.
What is happening? Is there any fix for this problem?
Thanks in advance.