The SyntaxEditor doesn't support direct binding to the internal text. This is because the content is not a plain text, but a more complex document model stored in the TextDocument class. To achieve your requirement you can store the TextDocument object in your view model and work with it when necessary.
Or you can try to implement a custom synchronization between the text in your view model and the content in the TextDocument. For example, when the text in the view model changes, you can clear the document and insert the new text.
syntaxEditor.Document.Delete(new Span(0, syntaxEditor.Document.CurrentSnapshot.Length));
When the text in the UI changes, you can use the TextContentChanged event of the TextDocument.
private void TextDocument_TextContentChanged(object sender, TextContentChangedEventArgs e)
var newText = e.AfterChangeSnapshot.GetText();
I hope this helps.
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin
, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.