/// <summary>
        /// Event handler for ApplicationCommands.Copy command.
        /// <remarks>
        /// We want to enforce that data can be set on the clipboard
        /// only in plain text format from this RichTextBox.
        /// </remarks>
        /// </summary>
        private static void OnCopy(object sender, ExecutedRoutedEventArgs e)
        {
            PlainRichTextBox myRichTextBox = (PlainRichTextBox)sender;
            string           selectionText = myRichTextBox.Selection.Text;

            Clipboard.SetText(selectionText);
            e.Handled = true;
        }
        /// <summary>
        /// Event handler for ApplicationCommands.Paste command.
        /// <remarks>
        /// We want to allow paste only in plain text format.
        /// </remarks>
        /// </summary>
        private static void OnPaste(object sender, ExecutedRoutedEventArgs e)
        {
            PlainRichTextBox myRichTextBox = (PlainRichTextBox)sender;

            // Handle paste only if clipboard supports text format.
            if (Clipboard.ContainsText())
            {
                myRichTextBox.Selection.Text = Clipboard.GetText();
            }
            e.Handled = true;
        }
        /// <summary>
        /// CanExecute event handler for ApplicationCommand.Paste.
        /// </summary>
        private static void OnCanExecutePaste(object target, CanExecuteRoutedEventArgs args)
        {
            PlainRichTextBox myRichTextBox = (PlainRichTextBox)target;

            args.CanExecute = myRichTextBox.IsEnabled && !myRichTextBox.IsReadOnly && Clipboard.ContainsText();
        }
        /// <summary>
        /// CanExecute event handler for ApplicationCommands.Cut.
        /// </summary>
        private static void OnCanExecuteCut(object target, CanExecuteRoutedEventArgs args)
        {
            PlainRichTextBox myRichTextBox = (PlainRichTextBox)target;

            args.CanExecute = myRichTextBox.IsEnabled && !myRichTextBox.IsReadOnly && !myRichTextBox.Selection.IsEmpty;
        }