Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't bind text to Text property #387

Open
danilwhale opened this issue Dec 11, 2023 · 5 comments
Open

Can't bind text to Text property #387

danilwhale opened this issue Dec 11, 2023 · 5 comments

Comments

@danilwhale
Copy link

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

@antonio-valentini-ilv
Copy link

I'm getting the same error 😭
Versions:

  • Avalonia 11.0.5
  • AvaloniaEdit 11.0.5

@antonio-valentini-ilv
Copy link

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.

@enif77
Copy link

enif77 commented Dec 14, 2023

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.

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.

@Dynesshely
Copy link

The best practice at now is to create a converter that accept string and return Document.

For example:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants
@enif77 @Dynesshely @danilwhale @antonio-valentini-ilv and others