-
Notifications
You must be signed in to change notification settings - Fork 16
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
Need help with initialization of style/theme, for use with AvaloniaEdit #38
Comments
@iksi4prs hey! Can you provide minimal project sample, that I can build locally to reproduce that situation? |
@gritsenko , The solution includes 2 apps that uses the "Edit", one with xaml and one with markup, I'm not sure what is the problem, but when debugging, I've noticed the difference mentioned earlier, see "OnApplyTemplate" in file AvaloniaEdit\TextEditor.cs The ExampleXaml is based on https://github.com/AvaloniaUI/AvaloniaEdit/tree/master/src/AvaloniaEdit.Demo 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. 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, 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. Thanks again for your help. |
I don't think this is critical issue for now. Anyway, you can update your sample with the correct code and add some notes to it into readme file, so it will help in future for those people who will face similar problems in future :-) |
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
The text was updated successfully, but these errors were encountered: