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

Runtime theme changing problems on Avalonia 11 #200

Closed
SKProCH opened this issue Dec 4, 2022 · 7 comments
Closed

Runtime theme changing problems on Avalonia 11 #200

SKProCH opened this issue Dec 4, 2022 · 7 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@SKProCH
Copy link
Collaborator

SKProCH commented Dec 4, 2022

If you install 3.0.0-preview* version and setup theme changing at runtime you can get troubles with, for example, TextBox colors (and left side bar in our demo):
b658ae27-15d2-46e0-a29b-e6ed98065b01

This is known error and i don't know how to fix it. I think what that is something at Avalonia's side.
I figured out some workarounds:

  1. You can set UseCompositor = false and UseDeferredRendering = false at your BuildAvaloniaApp method:
    image
    Make sure what you creating proper PLATFORMOptions, where PLATFORM is your platform actually.
  2. You can use InvalidateVisual at root element of scene (or at elements what incorrectly painted). After that you should trigger actual repainting of everything - for example, change window size

Also, i need your help to find out exactly what causes this behavior, create a minimal representative example, and help the Avalonia developers fix it (or fix it on our end, but I have no idea). All ideas, PR, examples and other warmly welcomed.

@SKProCH SKProCH added bug Something isn't working help wanted Extra attention is needed labels Dec 4, 2022
@SKProCH SKProCH pinned this issue Dec 4, 2022
@appleneko2001
Copy link
Collaborator

I thought UseDeferredRendering wont affect this.
might we need research our theme applying procedure(((
I can try to addressing the reason of this glitch and fix workaround(if possible)

@appleneko2001
Copy link
Collaborator

Wait if InvalidateVisual helps then it means procedure cannot notify avalonia that resources has changed
use Dispatcher invoking notify changes workaround?

@SKProCH
Copy link
Collaborator Author

SKProCH commented Dec 6, 2022

I thought UseDeferredRendering wont affect this. might we need research our theme applying procedure((( I can try to addressing the reason of this glitch and fix workaround(if possible)

I've already researched our theme applying - it's working fine and as intended. I may have missed something, of course, but I'm sure that's not where the problem is.

Wait if InvalidateVisual helps then it means procedure cannot notify avalonia that resources has changed
use Dispatcher invoking notify changes workaround?

I don't really know what you mean. The change events themselves are generated normally

@SKProCH
Copy link
Collaborator Author

SKProCH commented Dec 11, 2022

Interesting fact: if we replace <TextBlock Classes="Body2" Text="Home" /> in ListBox in demo's MainWindow with just Home text - it will be change colors fine.

Here is gif:
335db45d-4af2-485a-ba0c-672866514e21

<ListBox Classes="NoScroll" Name="DrawerList"
         Focusable="{Binding ElementName=LeftDrawer, Path=LeftDrawerOpened}">
  <TextBlock>Home</TextBlock>
    Home
    Buttons
    ...

@SKProCH
Copy link
Collaborator Author

SKProCH commented Dec 11, 2022

Seems like, if we reset theme at runtime, all controls start working fine.

Step by step:

  1. Controls (TextBlock, TextBox) doesn't react to theme changing
  2. Remove MaterialTheme from App.Styles completely
  3. Add back MaterialTheme to App.Styles
  4. Control are reacting to theme changes fine now
    But this is doesn't work for controls which created after theme reattaching. (for example, we have buggy controls at Home tab, do reattach, buggy controls fixed, after that we switch to Fields (TextBox'es) tab, everything doesn't work property for textboxes)

@SKProCH
Copy link
Collaborator Author

SKProCH commented Dec 11, 2022

Seems like i figured out it in more details

@SKProCH
Copy link
Collaborator Author

SKProCH commented Feb 16, 2023

Fixed with Avalonia 11 preview 5.

@SKProCH SKProCH closed this as completed Feb 16, 2023
@SKProCH SKProCH unpinned this issue Feb 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants