Xamarin.Forms AppThemeBinding markup extension
I really like the new AppThemeBinding
markup extension in Xamarin.Forms to easily handle Dark and Light modes on the mobile device. It can be used in combination with the StaticResource
markup extension.
Below is an example:
BackgroundColor="{AppThemeBinding
Light={StaticResource LightBackgroundColor},
Dark={StaticResource DarkBackgroundColor}}"
<ContentPage.Resources>
<Color x:Key="LightBackgroundColor">WhiteSmoke</Color>
<Color x:Key="DarkBackgroundColor">Black</Color>
</ContentPage.Resources>
screen recording on iPhone Simulator