Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > Avalon

Vista - Reusing a color

 
 
Old 07-07-2006   #1 (permalink)
=?Utf-8?B?RHVxdWUgVmllaXJh?=


 
 

Reusing a color

Hello.

I have a custom control that has a Color property.
In this control's style I want to use this color with different Alpha values.
And I want to do this using just XAML.

I've tried some tricks like setting a <Color> element in the Resources
section binding it to the control's Color.
Then, I tried to get each of the R, G and B values into a new <Color>
element in the Resources.
In this <Color> element I would change the Alpha value and get the color I
wanted, but it doesn't seem to work...

Anyway, it seems to complicated to my likings...

Any ideas? Thanks.

--
Duque Vieira

My System SpecsSystem Spec
Old 07-08-2006   #2 (permalink)
Adam Smith [MS]


 
 

Re: Reusing a color

Color is a struct, not a DependencyObject, so its individual properties are
not DependencyProperties. As such, you cannot set their values to dynamic
resource references, databindings, etc. You can write a data converter
which will multi-bind to a color and an opacity and combine them to form a
new color - while this will be code, all of the usage will be in markup.
Alternately, many places where you can use a Color in WPF also allows you to
set the Opacity independently, such as SolidColorBrush.Color and
SolidColorBrush.Opacity. This is not universally available (e.g.
GradientStop doesn't have an Opacity property), but it's something to
consider depending on your scenario.

-Adam Smith [MS]

"Duque Vieira" <duquevieira@modellus.com> wrote in message
news:12E5B1A9-0A0F-4CEF-A765-49C5CE385A54@microsoft.com...
> Hello.
>
> I have a custom control that has a Color property.
> In this control's style I want to use this color with different Alpha
> values.
> And I want to do this using just XAML.
>
> I've tried some tricks like setting a <Color> element in the Resources
> section binding it to the control's Color.
> Then, I tried to get each of the R, G and B values into a new <Color>
> element in the Resources.
> In this <Color> element I would change the Alpha value and get the color I
> wanted, but it doesn't seem to work...
>
> Anyway, it seems to complicated to my likings...
>
> Any ideas? Thanks.
>
> --
> Duque Vieira



My System SpecsSystem Spec
 

Thread Tools


Similar Threads
Thread Forum
Can't change Color of pages using color/appearance Vista installation & setup
reusing cd-key? Vista installation & setup
Reusing The Activation Key Vista General
Not all color names give right color? PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46