Two Way Binding to AvalonEdit Document Text using MVVM

Create a Behavior class that will attach the TextChanged event and will hook up the dependency property that is bound to the ViewModel. AvalonTextBehavior.cs public sealed class AvalonEditBehaviour : Behavior<TextEditor> { public static readonly DependencyProperty GiveMeTheTextProperty = DependencyProperty.Register(“GiveMeTheText”, typeof(string), typeof(AvalonEditBehaviour), new FrameworkPropertyMetadata(default(string), FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, PropertyChangedCallback)); public string GiveMeTheText { get { return (string)GetValue(GiveMeTheTextProperty); } set { … Read more

AvalonEdit: Cascading HighlightingColorizers

The problem is that the HighlightingColorizer does not directly store a reference to the DocumentHighlighter, but instead stores it via TextView.Services. This is done to allow attaching the same colorizer to multiple editors, so that each editor gets its own DocumentHighlighter. When you attach a second colorizer, it overwrites the IHighlighter stored in the service … Read more