Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > Avalon

Reusing a color

Closed Thread
 
Thread Tools Display Modes
Old 07-07-2006   #1 (permalink)
=?Utf-8?B?RHVxdWUgVmllaXJh?=
Guest


 

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
Old 07-08-2006   #2 (permalink)
Adam Smith [MS]
Guest


 

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



Closed Thread

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't change Color of pages using color/appearance Nate Vista installation & setup 1 12-24-2007 12:27 AM
reusing cd-key? Liam Richmond Vista installation & setup 1 09-19-2007 05:25 AM
Reusing The Activation Key Robert Vista General 6 02-23-2007 12:54 PM
Not all color names give right color? Lucvdv PowerShell 3 11-08-2006 05:59 AM
FindResource problem( Reusing Drawings ) Adam Smith [MS] Avalon 3 09-07-2006 11:41 AM








Vistax64.com 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 2005-2008

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 47 48 49 50