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

DynamicResource for TransparencyBackgroundFallback not working #16097

Open
StefanKoell opened this issue Jun 24, 2024 · 3 comments
Open

DynamicResource for TransparencyBackgroundFallback not working #16097

StefanKoell opened this issue Jun 24, 2024 · 3 comments
Labels

Comments

@StefanKoell
Copy link

Describe the bug

As discussed here: #16091

When using a dynamic resource in TransparencyBackgroundFallback on a Window, it doesn't honor the light and dark variant resource based on the actual theme. Switching the theme will leave you stuck with the initial value.

To Reproduce

Create an empty project and set the following properties on a Window:

    TransparencyBackgroundFallback="{DynamicResource ThemeBackgroundBrush}"
    TransparencyLevelHint="Mica,Transparent"

Toggling the theme during runtime when Mica is not available does not use the ThemeBackgroundBrush for the current theme.

Expected behavior

Toggling the theme during runtime when Mica is not available should use the ThemeBackgroundBrush for the current theme.

Avalonia version

11.1.0-rc1

OS

Windows

Additional context

No response

@maxkatz6
Copy link
Member

This property is read only in this event handled

if (transparencyLevel == WindowTransparencyLevel.None)
{
_transparencyFallbackBorder.Background = TransparencyBackgroundFallback;
}
else
{
_transparencyFallbackBorder.Background = null;
}
, when TransparencyLevel was changed. There is no subscription on property itself changing.

@maxkatz6
Copy link
Member

Possibly, 748 line should be replaced with a .Bind call.

@StefanKoell
Copy link
Author

Thanks for the feedback! I'm happy to submit a PR but I'm not sure what the right way would be to improve the code. Do I just call the Bind method for that property? Do I need to take care of disposal of the binding?

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

No branches or pull requests

2 participants