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

ShadeEffect crashes with unhandled error with a ThemeResource #4981

Open
3 of 14 tasks
bjorn-malmo opened this issue Apr 10, 2024 · 1 comment
Open
3 of 14 tasks

ShadeEffect crashes with unhandled error with a ThemeResource #4981

bjorn-malmo opened this issue Apr 10, 2024 · 1 comment
Labels
bug 🐛 An unexpected issue that highlights incorrect behavior

Comments

@bjorn-malmo
Copy link

Describe the bug

Assigning a ThemeResource in XAML for the Color property of ShadeEffect throws the following exception:

Exception thrown: 'System.Runtime.InteropServices.COMException' in System.Private.CoreLib.dll
WinRT information: Failed to assign to property 'CommunityToolkit.WinUI.UI.Media.ShadeEffect.Color'. [Line: 316 Position: 48]
An exception of type 'System.Runtime.InteropServices.COMException' occurred in System.Private.CoreLib.dll but was not handled in user code

Using a StaticResource works great.

The following XAML code will reproduce the issue:

<Window
    x:Class="App1.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:media="using:CommunityToolkit.WinUI.UI.Media">

    <Grid>
        <TextBlock Text="Text underneath a media effect"
                   HorizontalAlignment="Center"
                   VerticalAlignment="Center"/>

        <Grid Width="64" Height="64">
            <Grid.Background>
                <media:PipelineBrush Source="{media:BackdropSource}">
                    <media:BlurEffect Amount="2"/>
<!-- 
                    Any one of these will work:
                    
                    <media:ShadeEffect Color="Blue" Intensity="0.4"/>   
                    <media:ShadeEffect Color="{StaticResource SystemAccentColor}" Intensity="0.4"/> 
-->
                    
                    <!-- But this one doesn't -->
                    <media:ShadeEffect Color="{ThemeResource SystemAccentColor}" Intensity="0.4"/>
                    
                </media:PipelineBrush>
            </Grid.Background>
        </Grid>
    </Grid>
    
</Window>

Regression

No response

Reproducible in sample app?

  • This bug can be reproduced in the sample app.

Steps to reproduce

1. Create a new WinUI application
2. Replace the XAML for MainWindow with the one in the description above
3. Start the application

Expected behavior

Expected theme resource to "just work" the same as a static resource.

Screenshots

No response

Windows Build Number

  • Windows 10 1809 (Build 17763)
  • Windows 10 1903 (Build 18362)
  • Windows 10 1909 (Build 18363)
  • Windows 10 2004 (Build 19041)
  • Windows 10 20H2 (Build 19042)
  • Windows 10 21H1 (Build 19043)
  • Windows 11 21H2 (Build 22000)
  • Other (specify)

Other Windows Build number

No response

App minimum and target SDK version

  • Windows 10, version 1809 (Build 17763)
  • Windows 10, version 1903 (Build 18362)
  • Windows 10, version 1909 (Build 18363)
  • Windows 10, version 2004 (Build 19041)
  • Other (specify)

Other SDK version

No response

Visual Studio Version

2022

Visual Studio Build Number

No response

Device form factor

Desktop

Nuget packages

CommunityToolkit.WinUI.UI.Media 7.1.2

Additional context

No response

Help us help you

No.

@bjorn-malmo bjorn-malmo added the bug 🐛 An unexpected issue that highlights incorrect behavior label Apr 10, 2024
@riqmariz
Copy link

I was wondering, maybe the color that you're trying to pass is a SolidBrushColor instead of Color, they are from different libs. I had this problem on my project but was a type problem when I was declaring my theme resources. Hope it works for you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 An unexpected issue that highlights incorrect behavior
Projects
None yet
Development

No branches or pull requests

2 participants