Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

XAML resources: create color based on another color in the dictionary?

$
0
0

Let's say I have a ResourceDictionary with a color defined:

<Color x:Key="MyColor">#000</Color>

I need to create another color based on that color, with the alpha channel adjusted. I've tried creating a markup extension and using it like this:

<Color x:Key="MyOtherColor" x:FactoryMethod="FromHex" x:Arguments="{core:ModifyColor Other={StaticResource MyColor} Alpha=0.5 }" />

The extension returns the new color as a hex string.

However, it seems like the parser isn't getting the value from my extension before calling FromHex and I get the following error:

No static method found for Xamarin.Forms.Color::FromHex (Core.ModifyColorExtension)

I've been banging my head on the wall for hours now trying to figure this out.

I feel like there's gotta be an easy way to do this... am I wrong?


Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>