microsoft-ui-xaml icon indicating copy to clipboard operation
microsoft-ui-xaml copied to clipboard

Some StaticResource entries point to Color objects

Open FrayxRulez opened this issue 3 years ago • 1 comments

I noticed that some StaticResources defined in the library point to Color objects instead of their SolidColorBrush equivalent, but they're still used in place of actual brushes in the styles. An example is <StaticResource x:Key="RadioButtonOuterEllipseStrokePointerOver" ResourceKey="ControlStrongStrokeColorDefault" /> I was now wondering if this on purpose and in case what's the actual reason.

Sorry, I know I didn't use the right ticket template but I couldn't find a better fitting one 😅

FrayxRulez avatar Sep 06 '22 10:09 FrayxRulez

Color animations cannot point to a SolidColorBrush, only a Color.

marksfoster avatar Sep 13 '22 22:09 marksfoster

The Xaml markup parser does this as a convenience helper; automatically converting the Color into a SolidColorBrush.

So in this case ControlStrongStrokeColorDefault is a Color, consequently RadioButtonOuterEllipseStrokePointerOver is a Color, yet it can be set in markup to a (Brush-typed) Stroke property.

This implicit conversion is certainly useful, but kind of random on this one type, not part of a general feature. It would be useful to make it into a more generalized implicit conversion mechanism.

MikeHillberg avatar Oct 06 '22 21:10 MikeHillberg

@FrayxRulez asked: "I noticed that some StaticResources defined in the library point to Color objects instead of their SolidColorBrush equivalent"

RadioButtonOuterEllipseStrokePointerOver value points to a Color resource (ControlStrongStrokeColorDefault) and not a SolidColorBrush because if you look at the visual state using RadioButtonOuterEllipseStrokePointerOver:

<LinearColorKeyFrame KeyTime="{StaticResource ControlFasterAnimationDuration}" Value="{ThemeResource RadioButtonOuterEllipseStrokePointerOver}" />

<StaticResource x:Key="RadioButtonOuterEllipseStrokePointerOver" ResourceKey="ControlStrongStrokeColorDefault" />

<Color x:Key="ControlStrongStrokeColorDefault">#8BFFFFFF</Color>

You'll see it is a LinearColorKeyFrame which is part of a color animation (ColorAnimationUsingKeyFrames) that cannot use a SolidColorBrush, only a Color.

https://github.com/microsoft/microsoft-ui-xaml/blob/8ac2866a2b42165184a265181caa931f6638ccbd/dev/CommonStyles/RadioButton_themeresources.xaml#L270

marksfoster avatar Oct 07 '22 18:10 marksfoster

Closing this issue as By Design

bpulliam avatar Oct 29 '22 22:10 bpulliam