Dark mode - Xamarin

With Xamarin, you can detect dark mode by checking if the RequestedTheme property equals OSAppTheme.Dark.

In XAML you can use AppThemeBinding to define different resources for dark mode.

using Xamarin.Essentials;

OSAppTheme theme = Application.Current.RequestedTheme;
if (theme == OSAppTheme.Dark) {
    // Dark mode
}
<ContentPage>
    <StackLayout>
        <Label Text="This text is black in light mode and white in dark mode."
               TextColor="{AppThemeBinding Light=Black, Dark=White}" />
        <Image Source="{AppThemeBinding Light=logo_light.png, Dark=logo_dark.png}" />
    </StackLayout>
</ContentPage>