Hello,
You can do this by React to theme changes. Add the Application.Current.RequestedThemeChanged
to the MainPage
's constructor. If your theme changed, RequestedThemeChanged
event will be invoked, you can set different images by themes like following code.
public MainPage()
{
InitializeComponent();
BindingContext = this;
Application.Current.RequestedThemeChanged += (s, a) =>
{
// Respond to the theme change
if (a.RequestedTheme == OSAppTheme.Light)
{
ImgSource = "userstandardlight.png";
}
else
{
ImgSource = "userstandarddark.png";
}
};
}
Best Regards,
Leon Lu
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.