public void ToggleStrikethrough() { TextRange range = new TextRange(Selection.Start, Selection.End); TextDecorationCollection t = (TextDecorationCollection)Selection.GetPropertyValue(Inline.TextDecorationsProperty); if (t == null || !t.Equals(TextDecorations.Strikethrough)) { t = TextDecorations.Strikethrough; } else { t = new TextDecorationCollection(); } range.ApplyPropertyValue(Inline.TextDecorationsProperty, t); }
private void StrikeThroughButton_Click(object sender, RoutedEventArgs e) { TextRange range = new TextRange(richTextBox.Selection.Start, richTextBox.Selection.End); TextDecorationCollection tdc = (TextDecorationCollection)richTextBox.Selection.GetPropertyValue(Inline.TextDecorationsProperty); if (tdc == null || !tdc.Equals(TextDecorations.Strikethrough)) { tdc = TextDecorations.Strikethrough; } else { tdc = null; } range.ApplyPropertyValue(Inline.TextDecorationsProperty, tdc); }
// // ToolStripButton Strikeout wurde gedrückt // (läßt sich nicht durch Command in XAML abarbeiten) // private void ToolStripButtonStrikeout_Click(object sender, System.Windows.RoutedEventArgs e) { // TODO: Ereignishandlerimplementierung hier einfügen. TextRange range = new TextRange(RichTextControl.Selection.Start, RichTextControl.Selection.End); TextDecorationCollection tdc = (TextDecorationCollection)RichTextControl.Selection.GetPropertyValue(Inline.TextDecorationsProperty); if (tdc == null || !tdc.Equals(TextDecorations.Strikethrough)) { tdc = TextDecorations.Strikethrough; } else { tdc = new TextDecorationCollection(); } range.ApplyPropertyValue(Inline.TextDecorationsProperty, tdc); }
// // ToolStripButton Strikeout wurde gedrückt // (läßt sich nicht durch Command in XAML abarbeiten) // private void ToolStripButtonStrikeout_Click(object sender, System.Windows.RoutedEventArgs e) { try { // TODO: Ereignishandlerimplementierung hier einfügen. TextRange range = new TextRange(RichTextControl.Selection.Start, RichTextControl.Selection.End); TextDecorationCollection tdc = (TextDecorationCollection)RichTextControl.Selection.GetPropertyValue(Inline.TextDecorationsProperty); if (tdc == null || !tdc.Equals(TextDecorations.Strikethrough)) { tdc = TextDecorations.Strikethrough; } else { tdc = new TextDecorationCollection(); } range.ApplyPropertyValue(Inline.TextDecorationsProperty, tdc); } catch (Exception ex) { MessageBox.Show(ex.Message + "\r\n\r\n" + ex.StackTrace, ex.GetType().Name, MessageBoxButton.OK, MessageBoxImage.Error); } }
private static void EditingCommandsEx_ToggleStrikethrough_Executed(Object sender, ExecutedRoutedEventArgs e) { var editor = sender as RichTextBox; if (e.Handled = editor != null) { RichTextBoxToolBarHelper.ToggleSelectionFormattingProperty <TextDecorationCollection>(editor.Selection, Inline.TextDecorationsProperty, TextDecorations.Strikethrough, null, (item1, item2) => TextDecorationCollection.Equals(item1, item2)); } }