AvaloniaEdit
AvaloniaEdit copied to clipboard
Can't bind text to Text property
i get this when trying to build project:
Error AVLN:0004 Avalonia: Unable to find suitable setter or adder for property Text of type AvaloniaEdit:AvaloniaEdit.TextEditor for argument Avalonia.Markup.Xaml:Avalonia.Markup.Xaml.MarkupExtensions.CompiledBindingExtension, available setter parameter lists are:
--
2 | System.String Line 138, position 50.
here is my code:
<AvaloniaEdit:TextEditor Text="{Binding Code}"
ShowLineNumbers="True"/>
my Code property is string, no issues happen when i bind it to TextBlock
I'm getting the same error 😭 Versions:
- Avalonia
11.0.5
- AvaloniaEdit
11.0.5
One possible workaround seems to be binding to the Document
property of the TextEditor
instead of the Text
property, using a TextDocument
instance inside the view model.
One possible workaround seems to be binding to the
Document
property of theTextEditor
instead of theText
property, using aTextDocument
instance inside the view model.
That is, what I ended up using too. Its not pretty, because now my view model contains a type specific to the used UI/control.
The best practice at now is to create a converter that accept string
and return Document
.
For example:
There is a way provided by the wiki, I love it. https://github.com/AvaloniaUI/AvaloniaEdit/wiki/MVVM#create-behaviour