You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
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!
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:
Regression
No response
Reproducible in sample app?
Steps to reproduce
Expected behavior
Expected theme resource to "just work" the same as a static resource.
Screenshots
No response
Windows Build Number
Other Windows Build number
No response
App minimum and target SDK version
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.
The text was updated successfully, but these errors were encountered: