Replies: 2 comments 7 replies
-
I love this feature, especially if it works with I'll let @michael-hawker chime in on the best architecture |
Beta Was this translation helpful? Give feedback.
6 replies
-
It is a pity that so many classes are sealed. Deriving from the SolidColorBrush would be so wonderful. @michael-hawker How can I help to create that small repo? |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm playing with some experiments for changing the brightness of a Color using a correction factor.
Have a look at the following examples it shows two rows (horizontal StackPanels) of blue rectangles which start dark and light up for the next one. You can find this example on https://github.com/sonnemaf/ColorBrightnessDemoApp
The Xaml looks like this.
I tried two different solutions.
Attached Property
In the first StackPanel I used an
Attachted Property
toDarken
orLighten
theColor
of aSolidColorBrush
.This solution works fine but uses a
DispatcherQueue.TryEnqueue
hack to postpone the color correction. This is necessary if the CorrectionFactor is set before the Color is set.This solution is specific for the
SolidColorBrush
. AGradientBrush
would need one too.Markup extension
The second one is using a
Markup Extension
toDarken
orLighten
aColor
. Can be any Color. Also usable in aGradientBrush
.This solution has the limitation that it doesn't work with ThemeResources. It will just crash the app. See example below.
Questions
Remark
To get this working I created a ColorHelper class with a
Darken
andLighten
extension methods on Color. Couldn't find the ColorHelper from the toolkit. Is it gone?Beta Was this translation helpful? Give feedback.
All reactions