

In this example, the background color of the Grid and the Button style changes based on whether the device is using its light theme or dark theme. In addition, resources defined in a ResourceDictionary can be consumed with the StaticResource markup extension: Similarly, the Image displays a different image file based upon the current system theme. In this example, the text color of the first Label is set to green when the device is using its light theme, and is set to red when the device is using its dark theme. The following XAML example shows how to use the AppThemeBinding markup extension: Therefore, for XAML markup expressions expressed with curly braces, you can eliminate the Default= part of the expression provided that it's the first argument. The Default property is the content property of AppThemeBindingExtension. The XAML parser allows the AppThemeBindingExtension class to be abbreviated as AppBindingTheme.



The AppThemeBinding markup extension enables you to consume a resource, such as an image or color, based on the current system theme. In addition, objects that consume these resources are automatically updated if the system theme changes while an app is running. With these approaches, resources are automatically applied based on the value of the current system theme. Resources for light and dark themes can be consumed with the AppThemeBinding markup extension, and the SetAppThemeColor and SetAppTheme extension methods. The following screenshot shows themed pages, for the light system theme on iOS and the dark system theme on Android: NET MAUI apps can respond to system theme changes on iOS 13 or greater, Android 10 (API 29) or greater, macOS 10.14 or greater, and Windows 10 or greater.
