How to use Dark Theme Light Theme in Xamarin Forms? RRS feed

  • Question

  • User366103 posted

    I am new to Xamarin Forms, I want to use a logo that changes based on the device mode, if it's dark mode, the logo will be white and if it's light mode, the logo will be black. I only found examples on how to do it for colors by adding them to the resource dictionaries(the example is attached below), I tried to do it for the logo, but It didn't work.Can someone share tips or a link of a tutorial that show how to do that?

    <!--  Colours  -->
    <!--<Color x:Key="MainPage">#F58220</Color>-->

    Tuesday, March 3, 2020 10:17 PM

All replies

  • User386272 posted

    FYI. https://help.syncfusion.com/xamarin/themes/themes

    Hope you get some idea.

    Wednesday, March 4, 2020 10:40 AM
  • User395669 posted

    @Helloo You should try this

    Change App.cs to App.xml

    Monday, March 8, 2021 9:28 AM
  • User399931 posted

    is this dark mode still in function?

    Monday, March 15, 2021 3:47 PM
  • User392521 posted

    You can change the image source according to the app theme

    <Image Source="{AppThemeBinding Light=light_theme_logo.png, Dark=dark_theme_logo.png}" />

    FYI, If you want to change any label text color / any other views foreground or background-color change according to app theme use the below code.


    ``` If you want change thems on button click, use below code

    ``` Application.Current.UserAppTheme = OSAppTheme.Unspecified; // Your device settings decide whether to show light or dark mode.

    Application.Current.UserAppTheme = OSAppTheme.Dark; // To activate dark theme

    Application.Current.UserAppTheme = OSAppTheme.Light; // To activate light theme ```

    Thursday, March 25, 2021 11:54 AM