![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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. |
| |||||||
| |
| | #1 (permalink) |
| | 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 Specs![]() |
| | #2 (permalink) |
| | 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 Specs![]() |
| 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 | |||