Example #1
0
        void ICommand.Execute(object parameter)
        {
            var target = GetDataContext(this._target);

            if (this._target != null)
            {
                bool canExecute;
                CommandExecutionManager.TryExecuteCommand(target, parameter, true, this.Executed, this.CanExecute, out canExecute);
            }
        }
Example #2
0
        /// <summary>
        ///     The method that is called when the Executed <see cref="RoutedEvent"/> for the
        ///     <see cref="ICommand"/> associated with this <see cref="DataContextCommandBinding"/>
        ///     should be handled.
        /// </summary>
        /// <param name="sender">The command target on which the command is executing.</param>
        /// <param name="e">The event data.</param>
        protected internal override void OnExecuted(object sender, ExecutedRoutedEventArgs e)
        {
            var  target = GetDataContext(sender);
            bool canExecute;

            if (CommandExecutionManager.TryExecuteCommand(target, e.Parameter, true, this.Executed, this.CanExecute, out canExecute))
            {
                e.Handled = true;
            }
        }
Example #3
0
        /// <summary>
        ///     The method that is called when the PreviewCanExecute <see cref="RoutedEvent"/> for the
        ///     <see cref="ICommand"/> associated with this <see cref="DataContextCommandBinding"/>
        ///     should be handled.
        /// </summary>
        /// <param name="sender">The command target on which the command is executing.</param>
        /// <param name="e">The event data.</param>
        protected internal override void OnPreviewCanExecute(object sender, CanExecuteRoutedEventArgs e)
        {
            var  target = GetDataContext(sender);
            bool canExecute;

            if (CommandExecutionManager.TryExecuteCommand(target, e.Parameter, false, this.PreviewExecuted, this.PreviewCanExecute, out canExecute))
            {
                e.CanExecute = canExecute;
                e.Handled    = true;
            }
        }
Example #4
0
        bool ICommand.CanExecute(object parameter)
        {
            var target = GetDataContext(this._target);

            if (this._target != null)
            {
                bool canExecute;
                if (CommandExecutionManager.TryExecuteCommand(target, parameter, false, this.Executed, this.CanExecute, out canExecute))
                {
                    return(canExecute);
                }
            }
            return(false);
        }