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

[WinAppSdk] Brush Opacity Animation not working #18799

Open
kucint opened this issue Nov 15, 2024 · 4 comments
Open

[WinAppSdk] Brush Opacity Animation not working #18799

kucint opened this issue Nov 15, 2024 · 4 comments
Labels
area/external Categorizes an issue or PR as being external to the Uno

Comments

@kucint
Copy link

kucint commented Nov 15, 2024

Current behavior

On WinAppSdk framework: DoubleAnimation of brush opacity is not working
On Desktop framework: works fine

<Page.Resources>
    <ResourceDictionary>
        <ResourceDictionary.ThemeDictionaries>
            <ResourceDictionary x:Key="Light">
                <Color x:Key="SpotlightColor">LightYellow</Color>
            </ResourceDictionary>
            <ResourceDictionary x:Key="Dark">
                <Color x:Key="SpotlightColor">LightGreen</Color>
            </ResourceDictionary>
        </ResourceDictionary.ThemeDictionaries>
    </ResourceDictionary>
</Page.Resources>

<Grid x:Name ="Topmost">
    <VisualStateManager.VisualStateGroups>
        <VisualStateGroup x:Name="SpotlightStates">
            <VisualState x:Name="SpotlightOn">
                <Storyboard>
                    <DoubleAnimation Storyboard.TargetName="TopmostBackgroundBrush" Storyboard.TargetProperty="(Brush.Opacity)" To="1.0" Duration="0:0:0.2" />
                </Storyboard>
            </VisualState>
            <VisualState x:Name="SpotlightOff">
                <Storyboard>
                    <DoubleAnimation Storyboard.TargetName="TopmostBackgroundBrush" Storyboard.TargetProperty="(Brush.Opacity)" To="0.0" Duration="0:0:0.2" />
                </Storyboard>
            </VisualState>
        </VisualStateGroup>
    </VisualStateManager.VisualStateGroups>

    <Grid.Background>
        <SolidColorBrush x:Name="TopmostBackgroundBrush" Color="{ThemeResource SpotlightColor}" Opacity="1"/>
    </Grid.Background>
    
    <CheckBox Content="Spotlight"
              IsChecked="True"
              HorizontalAlignment="Center"
              VerticalAlignment="Center"
              Checked="SpotlightCheckBox_Checked"
              Unchecked="SpotlightCheckBox_Unchecked" />
</Grid>
private void SpotlightCheckBox_Checked(object sender, RoutedEventArgs e)
    => VisualStateManager.GoToState(this, "SpotlightOn", true);

private void SpotlightCheckBox_Unchecked(object sender, RoutedEventArgs e)
    => VisualStateManager.GoToState(this, "SpotlightOff", true);

Expected behavior

On WinAppSdk framework: DoubleAnimation of brush opacity shall work as on Desktop

How to reproduce it (as minimally and precisely as possible)

MINIMAL REPRO PROJECT: UnoBrushOpacityAnimationApp.zip

STEPS TO REPRODUCE:

  • Run the App
    image
  • click on Spotlight checkbox
  • nothing happens on WinAppSdk, on Desktop all is fine

Workaround

No response

Works on UWP/WinUI

No

Environment

No response

NuGet package version(s)

"Uno.Sdk": "5.5.43"
"version": "9.0.100" // dotnet

Affected platforms

Windows (WinAppSDK)

IDE

Visual Studio 2022

IDE version

No response

Relevant plugins

No response

Anything else we need to know?

No response

@kucint kucint added difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. kind/bug Something isn't working triage/untriaged Indicates an issue requires triaging or verification labels Nov 15, 2024
@jeromelaban
Copy link
Member

Thanks for the report. WinAppSDK issues we won't be able to fix, and those should generally be reported directly to the winui repository.

Still, there may be another way to do this on WinUI to make it work.

@jeromelaban jeromelaban added area/external Categorizes an issue or PR as being external to the Uno and removed kind/bug Something isn't working triage/untriaged Indicates an issue requires triaging or verification difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. labels Nov 15, 2024
@kucint
Copy link
Author

kucint commented Nov 17, 2024

@jeromelaban
I fully understand.
what would be a workaround, can you please give me a hint?

@MartinZikmund
Copy link
Member

@kucint A way would be to create two colors - normal one and one with opacity applied. Then you could do a ColorAnimation between those two and that should hopefully work

@kucint
Copy link
Author

kucint commented Nov 19, 2024

Good idea. I'll check it out. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/external Categorizes an issue or PR as being external to the Uno
Projects
None yet
Development

No branches or pull requests

3 participants