Пример #1
0
        public Task Execute(RoutedCommand command, object target, object parameter, CancellationToken?token = null)
        {
            target = WpfObjectProxy.UnwrapIfProxy(target);

            if (!(target is IInputElement))
            {
                throw new InvalidOperationException("Cannot execute command on " + ToString());
            }

            parameter = WpfObjectProxy.UnwrapIfProxy(parameter);
            return(InvokeAsync(() => command.Execute(parameter, target as IInputElement), token: token ?? DefaultCancellationToken));
        }
Пример #2
0
        public bool CanExecute(RoutedCommand command, object target, object parameter)
        {
            target = WpfObjectProxy.UnwrapIfProxy(target);

            if (!(target is IInputElement))
            {
                return(false);
            }

            parameter = WpfObjectProxy.UnwrapIfProxy(parameter);
            return(Invoke(
                       () => command.CanExecute(parameter, (IInputElement)target),
                       DispatcherPriority.SystemIdle
                       ));
        }