protected TextArea(TextView textView) { if (textView == null) { throw new ArgumentNullException("textView"); } TextView = textView; TextView.SetBinding(TextView.DocumentProperty, new Binding("Document") { Source = this }); ReadOnlySectionProvider = NoReadOnlySections.Instance; LeftMargins = new ObservableCollection<UIElement>(); LeftMargins.Add(new LineNumberMargin { TextView = textView, TextArea = this }); LeftMargins.Add(new Line { X1 = 0, Y1 = 0, X2 = 0, Y2 = 1, StrokeDashArray = { 0, 2 }, Stretch = Stretch.Fill, Stroke = Brushes.Gray, StrokeDashCap = PenLineCap.Round, Margin = new Thickness(2, 0, 2, 0) }); var colorizer = new SelectionColorizer(this); TextView.LineTransformers.Add(colorizer); TextView.BackgroundRender.Add(colorizer); Caret = new Caret(this); CommandBindings.Add(new CommandBinding(ApplicationCommands.Undo, ExecuteUndo, CanExecuteUndo)); CommandBindings.Add(new CommandBinding(ApplicationCommands.Redo, ExecuteRedo, CanExecuteRedo)); CommandBindings.AddRange(CaretNavigationCommandHandler.CommandBindings); InputBindings.AddRange(CaretNavigationCommandHandler.InputBindings); CommandBindings.AddRange(EditingCommandHandler.CommandBindings); InputBindings.AddRange(EditingCommandHandler.InputBindings); new SelectionMouseHandler(this).Attach(); }