I keep getting a System.InvalidOperationException when using AppThemeBinding inside of OnPlatform on both Android and iOS.
<Application.Resources>
<Style x:Name="DefaultButton" TargetType="Button">
<Setter Property="TextColor">
<Setter.Value>
<OnIdiom x:TypeArguments="Color">
<OnIdiom.Phone>
<OnPlatform x:TypeArguments="Color">
<On Platform="Android, iOS" Value="{AppThemeBinding Light={AppThemeBinding Light=Green, Dark=Red}}"/>
</OnPlatform>
</OnIdiom.Phone>
<OnIdiom.TV>#FFFFFF</OnIdiom.TV>
</OnIdiom>
</Setter.Value>
</Setter>
</Style>
</Application.Resources>
@StephaneDelcroix
You can't use an AppThemeBinding to set a property of OnPlatform, as those props aren't Bindable.
I'm keeping this open as you should get a better error message.
If you want this to work, you might have some success by using BindingBase as x:TypeArguments
@StephaneDelcroix (sorry I saw late the closed issue https://github.com/xamarin/Xamarin.Forms/issues/10973) I believe even without OnPlatform it will throw an exception I mention the code snippet from https://github.com/xamarin/Xamarin.Forms/issues/10973#issuecomment-651676520
<ContentPage.Resources>
<AppThemeBinding x:Key="FancyColor" x:Shared="false">
<AppThemeBinding.Light><Color>HotPink</Color></AppThemeBinding.Light>
<AppThemeBinding.Dark><Color>LimeGreen</Color></AppThemeBinding.Dark>
</AppThemeBinding>
</ContentPage.Resources>
<StackLayout>
<Label BackgroundColor="{StaticResource FancyColor}"/>
<Label BackgroundColor="{StaticResource FancyColor}"/>
</StackLayout>
Throwing exception at the startup of the app
System.Reflection.TargetInvocationException: 'Exception has been thrown by the target of an invocation.'
I don't think I need to open a separate issue but if you think so I will.