private static void IsSelectableChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { if (d is TextBlock textBlock) { textBlock.SetValue(UIElement.FocusableProperty, true); textBlock.SetValue(FrameworkElement.FocusVisualStyleProperty, (object)null); InternalTextEditorHacker.Bind(textBlock); } }
// ! TextBlock public static void Bind(TextBlock tb) { var textContainer = TextContainerProperty.GetValue(tb); var editor = new InternalTextEditorHacker(textContainer, tb, false); IsReadOnlyProperty.SetValue(editor._internalTextEditor, true); TextViewProperty.SetValue(editor._internalTextEditor, TextContainerTextViewProperty.GetValue(textContainer)); }
static TextBlockSelectableService() { InternalTextEditorHacker.RegisterCommandHandlers(typeof(TextBlock), true, true, true); }