-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Fixing Button resources #10442
base: main
Are you sure you want to change the base?
Fixing Button resources #10442
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -262,9 +262,6 @@ | |||||||||||||
<!-- Elevation border brushes --> | ||||||||||||||
|
||||||||||||||
<LinearGradientBrush x:Key="ControlElevationBorderBrush" MappingMode="Absolute" StartPoint="0,0" EndPoint="0,3"> | ||||||||||||||
<!--<LinearGradientBrush.RelativeTransform> | ||||||||||||||
<ScaleTransform CenterY="0.5" ScaleY="-1" /> | ||||||||||||||
</LinearGradientBrush.RelativeTransform>--> | ||||||||||||||
<LinearGradientBrush.GradientStops> | ||||||||||||||
<GradientStop Offset="0.33" Color="{StaticResource ControlStrokeColorSecondary}" /> | ||||||||||||||
<GradientStop Offset="1.0" Color="{StaticResource ControlStrokeColorDefault}" /> | ||||||||||||||
|
@@ -312,15 +309,25 @@ | |||||||||||||
<SolidColorBrush x:Key="AccentButtonBackground" Color="{StaticResource SystemAccentColorLight2}" /> | ||||||||||||||
<SolidColorBrush x:Key="AccentButtonBackgroundPointerOver" Color="{StaticResource SystemAccentColorLight2}" Opacity="0.9" /> | ||||||||||||||
<SolidColorBrush x:Key="AccentButtonBackgroundPressed" Color="{StaticResource SystemAccentColorLight2}" Opacity="0.8" /> | ||||||||||||||
<!--<SolidColorBrush x:Key="AccentButtonBackgroundDisabled" ResourceKey="AccentFillColorDisabledBrush" />--> | ||||||||||||||
<SolidColorBrush x:Key="AccentButtonBackgroundDisabled" Color="{StaticResource AccentFillColorDisabled}" /> | ||||||||||||||
<SolidColorBrush x:Key="AccentButtonForeground" Color="{StaticResource TextOnAccentFillColorPrimary}" /> | ||||||||||||||
<SolidColorBrush x:Key="AccentButtonForegroundPointerOver" Color="{StaticResource TextOnAccentFillColorPrimary}" /> | ||||||||||||||
<SolidColorBrush x:Key="AccentButtonForegroundPressed" Color="{StaticResource TextOnAccentFillColorSecondary}" /> | ||||||||||||||
<!--<SolidColorBrush x:Key="AccentButtonForegroundDisabled" ResourceKey="TextOnAccentFillColorDisabled" />--> | ||||||||||||||
<!--<SolidColorBrush x:Key="AccentButtonBorderBrush" Color="{DynamicResource AccentControlElevationBorder}" />--> | ||||||||||||||
<!--<SolidColorBrush x:Key="AccentButtonBorderBrushPointerOver" Color="{DynamicResource AccentControlElevationBorder}" />--> | ||||||||||||||
<SolidColorBrush x:Key="AccentButtonForegroundDisabled" Color="{StaticResource TextOnAccentFillColorDisabled}" /> | ||||||||||||||
<LinearGradientBrush x:Key="AccentButtonBorderBrush" MappingMode="RelativeToBoundingBox" StartPoint="0,1" EndPoint="0,0"> | ||||||||||||||
<LinearGradientBrush.GradientStops> | ||||||||||||||
<GradientStop Offset="0.025" Color="{StaticResource ControlStrokeColorOnAccentSecondary}" /> | ||||||||||||||
<GradientStop Offset="0.075" Color="{StaticResource ControlStrokeColorOnAccentDefault}" /> | ||||||||||||||
</LinearGradientBrush.GradientStops> | ||||||||||||||
</LinearGradientBrush> | ||||||||||||||
<LinearGradientBrush x:Key="AccentButtonBorderBrushPointerOver" MappingMode="RelativeToBoundingBox" StartPoint="0,1" EndPoint="0,0"> | ||||||||||||||
<LinearGradientBrush.GradientStops> | ||||||||||||||
<GradientStop Offset="0.025" Color="{StaticResource ControlStrokeColorOnAccentSecondary}" /> | ||||||||||||||
<GradientStop Offset="0.075" Color="{StaticResource ControlStrokeColorOnAccentDefault}" /> | ||||||||||||||
</LinearGradientBrush.GradientStops> | ||||||||||||||
</LinearGradientBrush> | ||||||||||||||
<SolidColorBrush x:Key="AccentButtonBorderBrushPressed" Color="{DynamicResource ControlFillColorTransparent}" /> | ||||||||||||||
<!--<SolidColorBrush x:Key="AccentButtonBorderBrushDisabled" Color="{DynamicResource ControlFillColorTransparentBrush}" />--> | ||||||||||||||
<SolidColorBrush x:Key="AccentButtonBorderBrushDisabled" Color="{DynamicResource ControlFillColorTransparent}" /> | ||||||||||||||
<SolidColorBrush x:Key="ButtonBackground" Color="{StaticResource ControlFillColorDefault}" /> | ||||||||||||||
<SolidColorBrush x:Key="ButtonBackgroundPointerOver" Color="{StaticResource ControlFillColorSecondary}" /> | ||||||||||||||
<SolidColorBrush x:Key="ButtonBackgroundPressed" Color="{StaticResource ControlFillColorTertiary}" /> | ||||||||||||||
|
@@ -329,8 +336,18 @@ | |||||||||||||
<SolidColorBrush x:Key="ButtonForegroundPointerOver" Color="{StaticResource TextFillColorPrimary}" /> | ||||||||||||||
<SolidColorBrush x:Key="ButtonForegroundPressed" Color="{StaticResource TextFillColorSecondary}" /> | ||||||||||||||
<SolidColorBrush x:Key="ButtonForegroundDisabled" Color="{StaticResource TextFillColorDisabled}" /> | ||||||||||||||
<!--<SolidColorBrush x:Key="ButtonBorderBrush" Color="{StaticResource ControlElevationBorder}" />--> | ||||||||||||||
<!--<SolidColorBrush x:Key="ButtonBorderBrushPointerOver" Color="{StaticResource ControlElevationBorder}" />--> | ||||||||||||||
<LinearGradientBrush x:Key="ButtonBorderBrush" MappingMode="Absolute" StartPoint="0,0" EndPoint="0,3"> | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These should just re-use ControlElevationBorderBrush. I don't think there is any reason to duplicate this complicated Brush. Otherwise, it is duplicate code and any updates would then have to be done multiple places -- bad practice. WinUI does the same: https://github.com/microsoft/microsoft-ui-xaml/blob/589ced40542b9b4de2fddf0e58a1e3eecd164e2f/src/controls/dev/CommonStyles/Button_themeresources.xaml#L26-L27 I would ALWAYS review WinUI when making these types of changes. Edit: I believe the below syntax works in WPF. I spend more time with more modern XAML frameworks so this needs to be tested. <StaticResource
x:Key="ButtonBorderBrush"
ResourceKey="ControlElevationBorderBrush" />
<StaticResource
x:Key="ButtonBorderBrushPointerOver"
ResourceKey="ControlElevationBorderBrush" /> There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think that works, but let me give it a try. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I get the following error when I do the above. However, I have seen this syntax in other places, but the StaticExtension there is a subclass of StaticResourceExtension for that : https://github.com/Kinnara/ModernWpf/blob/master/ModernWpf/Markup/StaticResourceExtension.cs After that they can use the above syntax. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not actually sure what is going on here. The existing StaticResourceExtensions has this constructor as well: wpf/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/StaticResourceExtension.cs Lines 35 to 39 in a792086
Either way, this is useful functionality. Perhaps it is a good idea to support it in Vanilla WPF as well. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was looking further, the error seems to be thrown by a Debug.Assert statement here : wpf/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Markup/BamlRecordWriter.cs Line 563 in a792086
I don't know why this is here. I will open up an issue for this and try to find out what's the reasoning behind this. By the way, would you know how this works ? Does it create a copy of the actual resource or is just a reference to the original resource ? |
||||||||||||||
<LinearGradientBrush.GradientStops> | ||||||||||||||
<GradientStop Offset="0.33" Color="{StaticResource ControlStrokeColorSecondary}" /> | ||||||||||||||
<GradientStop Offset="1.0" Color="{StaticResource ControlStrokeColorDefault}" /> | ||||||||||||||
</LinearGradientBrush.GradientStops> | ||||||||||||||
</LinearGradientBrush> | ||||||||||||||
<LinearGradientBrush x:Key="ButtonBorderBrushPointerOver" MappingMode="Absolute" StartPoint="0,0" EndPoint="0,3"> | ||||||||||||||
<LinearGradientBrush.GradientStops> | ||||||||||||||
<GradientStop Offset="0.33" Color="{StaticResource ControlStrokeColorSecondary}" /> | ||||||||||||||
<GradientStop Offset="1.0" Color="{StaticResource ControlStrokeColorDefault}" /> | ||||||||||||||
</LinearGradientBrush.GradientStops> | ||||||||||||||
</LinearGradientBrush> | ||||||||||||||
<SolidColorBrush x:Key="ButtonBorderBrushPressed" Color="{StaticResource ControlStrokeColorDefault}" /> | ||||||||||||||
<SolidColorBrush x:Key="ButtonBorderBrushDisabled" Color="{StaticResource ControlStrokeColorDefault}" /> | ||||||||||||||
|
||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as for ButtonBorderBrush, ButtonBorderBrushPointerOver -- re-use the pre-existing brushes.