Replies: 1 comment 1 reply
-
try this: var newControl = new TextBlock();
SolutionExplorer.Content = new Func<IServiceProvider, object>(_ => new TemplateResult<Control>(newControl , null!)); I got it on the most current version from 01.09.23 |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Is there any way to set the Content of a Tool to an element created in code?
I tried to use this:
SolutionExplorer.Content = new TextBlock() { Text = "TEST" };
But I got this exception:
System.ArgumentException: 'Unexpected content Avalonia.Controls.TextBlock (Parameter 'templateContent')'
So I tried to set it using template functions like this:
SolutionExplorer.Content = new FuncTemplate<TextBlock>(() => new TextBlock() { Text = "TEST" });
But still got this error:
System.ArgumentException: 'Unexpected content Avalonia.Controls.Templates.FuncTemplate'1[Avalonia.Controls.TextBlock] (Parameter 'templateContent')'
Is it even possible to this without using a ViewLocator and MVVM?
Beta Was this translation helpful? Give feedback.
All reactions