How to access color from App.xaml in C# in Xamarin Forms?

isSelected ? (Color) Application.Current.Resources["Yellow"] : Color.White;

I think Conversion Color.FromHex() is not needed as you are defining resource as a color. Hope that helps.


Just in case if the Color is referenced in MergedDictionaries:

<ResourceDictionary>
    <ResourceDictionary.MergedDictionaries>
        <resources:Colors />
    </ResourceDictionary.MergedDictionaries>
</ResourceDictionary>

you'd need to get it like:

Application.Current.Resources.TryGetValue("Yellow", out var yellowColor)

If you use Application.Current.Resources["Yellow"] it will throw a key not found exception.

HIH


You should be able to access it like this Application.Current.Resources["Yellow"].

In case of a color it would be more like;

public Color BackgroundColor
{
    get { return IsSelected ? Application.Current.Resources["Yellow"].ToString() : Color.White }
}