开发者

Transparent accent color

I want to fade some elements (rectangles and ellipses) from the accent color to transparent using a LinearGradientBrush. However - the transparent color is always a color and it seems like the color "Transparent" is #00FFFFFF - that is white with 0% opacity.

I would like to fade fro开发者_如何学Pythonm PhoneAccentColor to PhoneTransparentAccentColor. So if my accent color is red I would like to fade to #00FF0000 and if it is green I would like to fade to #0000FF00.

I can't find any built in color resource for transparent accent so what are my options here? I've tried the options below but with no real success and I can't find much on this topic by normal search channels so I'm not really sure what I'm missing here.

Some suggestions I came up with (however with no real success as stated earlier):

  • Create a custom resource in code behind and push it into the application wide resource dictionary?
  • Can I expose a property on my ViewModels with the Color and bind to it?


I can't think of a way to specify a transparent accent color directly with xaml. I do have a couple of possible solutions.

If possible you could animate the opacity of the object rather than the color itself.

Of you could generate the color in code (probably during start up)

var accentColor = (Color)Application.Current.Resources["PhoneAccentColor"];
var transparentAccentColor = accentColor.A = 0;

You could then store the color as a resource and reference it in xaml.

Application.Current.Resources.Add("TransparentPhoneAccentColor", transparentAccentColor);

Hope this helps.


As a general guideline, avoid using gradients on the phone due to the colour support available.

You could try using an OpacityMask in your LinearGradientBrush to achieve your desired results though.

Although not applicable in your case as you're using the accent colour, if you were able to produce images including gradients you should see How can I correct color banding in windows phone 7? for detais on how to avoid banding.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜