Previously I was able to do something like this
<OnPlatform x:TypeArguments="Color" Android="{StaticResource Primary}"/>
Now that, that syntax is deprecated, I'm trying to do this:
<OnPlatform x:TypeArguments="Color">
<On Platform="Android">{StaticResource Primary}</On>
</OnPlatform>
but I'm getting the following error:
Cannot convert "{StaticResource Primary}" into Xamarin.Forms.Color
How should my syntax be?
Because StaticResource
is a markup extension, you can use it either through attribute usage, or element usage
For example, try this:
<OnPlatform x:TypeArguments="Color">
<On Platform="Android" Value="{StaticResource Primary}" />
</OnPlatform>
or,
<OnPlatform x:TypeArguments="Color">
<On Platform="Android">
<StaticResource Key="Primary" />
</On>
</OnPlatform>