Transparent accent color

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

I want to disappear from PhoneAccentColor to PhoneTransparentAccentColor. Therefore, 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 a transparent accent, so what are my options here? I tried the options below, but without real success, and I can’t find much on this topic with the usual search channels, so I'm not quite sure what I am missing here.

Some suggestions that I came up with (but without real success, as mentioned earlier):

  • Create your own resource in the code behind and paste it into a wide application resource dictionary?
  • Can I open a property on my ViewModels with Color and associate it?
+3
source share
2 answers

I cannot think of a way to specify a transparent accent color directly using xaml. I have several possible solutions.

If possible, you can animate the opacity of the object, not the color itself.

You can generate color in the code (perhaps during startup)

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

Then you can save the color as a resource and specify it in xaml.

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

Hope this helps.

+4

- .

OpacityMask LinearGradientBrush, .

, , , , Windows Phone 7? detais , .

+1

Source: https://habr.com/ru/post/1775713/


All Articles