Closed iksi4prs closed 5 months ago
@iksi4prs hey! Can you provide minimal project sample, that I can build locally to reproduce that situation?
@gritsenko , I've put an example here https://github.com/iksi4prs/Avalonia2
The solution includes 2 apps that uses the "Edit", one with xaml and one with markup, and all projects compiled with source code instead of nuget so can be debugged.
I'm not sure what is the problem, but when debugging, I've noticed the difference mentioned earlier, so maybe this is the cause.
see "OnApplyTemplate" in file AvaloniaEdit\TextEditor.cs
The ExampleXaml is based on https://github.com/AvaloniaUI/AvaloniaEdit/tree/master/src/AvaloniaEdit.Demo (Its basically the same, but resources files used for samples )
Thanks for your help !
Hey @iksi4prs ! I just researched your samples and found that on the xaml example there are following lines in App.xaml
<FluentTheme />
<StyleInclude Source="avares://AvaloniaEdit/Themes/Fluent/AvaloniaEdit.xaml" />
the equivalent of them in c# will be following lines in program.cs
.AfterSetup(b =>
{
b.Instance?.Styles.Add(new FluentTheme());
b.Instance?.Styles.Add((IStyle)AvaloniaXamlLoader.Load(
new Uri("avares://AvaloniaEdit/Themes/Fluent/AvaloniaEdit.xaml")));
I tried that in your sample and it works now
Hi @gritsenko , thanks for your help ! works nice. I really appreciate you took the time to check this.
Next question is more about AvalonEdit, but since you know what the problem was, maybe you have some suggestion how to do it. My knowledge of Avalonia is very basic.
In sake of "future proofing", I thought to add exception in AvalonEdit, in case the theme is not loaded.
Namely in the scenario of someone else adding AvalonEdit to his "Avalonia.Markup.Declarative" project, and he didn't add the code that you suggested, an exception will be thrown "missing theme... etc".
Do you have any suggestion where to put in in AvalonEdit code, is there a method during initialization where theme should already exist ?
It would be even better if this could be added in code of "Avalonia.Markup.Declarative" itself, so will work with all components that require extre xaml, not just AvalonEdit. I dont know if its possible.
Thanks again for your help.
Hi, I'm using this project for tests, so far with success, and I really like it. I'm trying to make use of "AvaloniaEdit" control ( https://github.com/AvaloniaUI/AvaloniaEdit ) in my project, but this doesn't seem to work. The actual result now, is the I see the control in visual-tree and logical-tree of the "F12 debugger", but control itself is not painted/working.
I've checked how it works in a xaml project, and see there is "OnApplyTemplate" inside AvaloniaEdit which is called on start, when next is called from Main
BuildAvaloniaApp().StartWithClassicDesktopLifetime(args);
and they also mention need to add in xaml:<StyleInclude Source="avares://AvaloniaEdit/Themes/Fluent/AvaloniaEdit.xaml" />
In the "markup declarative" app, this OnApplyTemplate inside AvaloniaEdit is not called. To make use of style/theme, I still used the code from example, like here: https://github.com/AvaloniaUI/Avalonia.Markup.Declarative/blob/master/src/Samples/AvaloniaMarkupSample/App.cs
Any idea what is need to do, to make markup code so that "OnApplyTemplate" will be invoke ?
Thanks for any help