Example #1
0
 /// <summary>
 /// Determines whether the <see cref="ScrollBar.ScrollHereCommand"/> command can execute.
 /// </summary>
 private static void CanExecuteScrollHereCommand(DependencyObject element, ICommand command, Object parameter, CanExecuteRoutedEventData data)
 {
     data.CanExecute = true;
 }
        /// <summary>
        /// Determines whether the <see cref="ApplicationCommands.Paste"/> command can execute.
        /// </summary>
        private static void CanExecutePaste(DependencyObject element, ICommand command, Object parameter, CanExecuteRoutedEventData data)
        {
            var textEditor = ((TextEditingControl)element).TextEditor;

            if (textEditor == null)
            {
                return;
            }

            data.CanExecute = textEditor.IsEnabled && !textEditor.IsReadOnly;
            data.Handled    = true;
        }
Example #3
0
 /// <summary>
 /// Determines whether a scroll command can execute.
 /// </summary>
 private static void CanExecuteScrollCommand(DependencyObject element, ICommand command, Object parameter, CanExecuteRoutedEventData data)
 {
     data.CanExecute = !((HScrollBar)element).IsPartOfScrollViewer;
 }
        /// <summary>
        /// Determines whether the <see cref="ApplicationCommands.Cut"/> command can execute.
        /// </summary>
        private static void CanExecuteCut(DependencyObject element, ICommand command, Object parameter, CanExecuteRoutedEventData data)
        {
            var textEditor = ((TextEditingControl)element).TextEditor;

            if (textEditor == null)
            {
                return;
            }

            if (textEditor.IsMasked)
            {
                data.CanExecute = false;
                data.Handled    = true;
                return;
            }

            data.CanExecute = textEditor.IsEnabled && !textEditor.IsReadOnly && textEditor.SelectionLength > 0;
            data.Handled    = true;
        }
        /// <summary>
        /// Determines whether the <see cref="EditingCommands.TabBackward"/> command can execute.
        /// </summary>
        private static void CanExecuteTabBackward(DependencyObject element, ICommand command, Object parameter, CanExecuteRoutedEventData data)
        {
            var textEditor = ((TextEditingControl)element).TextEditor;

            if (textEditor != null && textEditor.AcceptsTab && textEditor.IsEnabled)
            {
                data.CanExecute = true;
            }
            else
            {
                data.ContinueRouting = true;
            }
        }
        /// <summary>
        /// Determines whether the <see cref="EditingCommands.EnterParagraphBreak"/> command can execute.
        /// </summary>
        private static void CanExecuteEnterParagraphBreak(DependencyObject element, ICommand command, Object parameter, CanExecuteRoutedEventData data)
        {
            var textEditor = ((TextEditingControl)element).TextEditor;

            if (textEditor != null && textEditor.AcceptsReturn && textEditor.IsEnabled && !textEditor.IsReadOnly)
            {
                data.CanExecute = true;
            }
            else
            {
                data.ContinueRouting = true;
            }
        }
        /// <summary>
        /// Specifies that a command can execute if the text box is enabled and the caret is visible.
        /// </summary>
        private static void CanExecuteIsCaretVisible(DependencyObject element, ICommand command, Object parameter, CanExecuteRoutedEventData data)
        {
            var textEditor = ((TextEditingControl)element).TextEditor;

            if (textEditor == null || !textEditor.IsEnabled)
            {
                return;
            }

            if (textEditor.IsReadOnly && !textEditor.IsReadOnlyCaretVisible)
            {
                return;
            }

            data.CanExecute = true;
        }
Example #8
0
        /// <summary>
        /// Determines whether a scroll command can execute.
        /// </summary>
        private static void CanExecuteScrollCommand(DependencyObject element, ICommand command, Object parameter, CanExecuteRoutedEventData data)
        {
            var scrollBar = element as ScrollBar;

            if (scrollBar == null || data.OriginalSource != scrollBar)
            {
                return;
            }

            var @continue = data.ContinueRouting;

            var orientedScrollBar = (scrollBar.Orientation == Orientation.Horizontal) ? scrollBar.PART_HScrollBar : scrollBar.PART_VScrollBar;

            if (orientedScrollBar != null)
            {
                data.CanExecute = ((RoutedCommand)command).CanExecute(scrollBar.View, parameter, orientedScrollBar, out @continue);
                data.Handled    = true;
            }

            data.ContinueRouting = @continue;
        }