Setapp ios6/22/2023 ![]() Light, which indicates that the device is using its light theme. ![]() Unspecified, which indicates that the device is using an unspecified theme.The AppTheme enumeration defines the following members: The RequestedTheme property returns an AppTheme enumeration member. The current system theme can be detected by getting the value of the Application.RequestedTheme property: AppTheme currentTheme = In this example, the Image displays lightlogo.png when the device is using its light theme, and darklogo.png when the device is using its dark theme. Image.SetAppTheme(Image.SourceProperty, "lightlogo.png", "darklogo.png") The SetAppTheme method enables objects of type T to be specified that will be set on a target property based on the current system theme: Image image = new Image() In this example, the text color of the 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. Label.SetAppThemeColor(Label.TextColorProperty, Colors.Green, Colors.Red) The SetAppThemeColor method enables Color objects to be specified that will be set on a target property based on the current system theme: Label label = new Label() NET MAUI includes SetAppThemeColor and SetAppTheme extension methods that enable VisualElement objects to respond to system theme changes. 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. Value, of type object, that returns the resource that's currently being used by the markup extension.Dark, of type object, that you set to the resource to be used when the device is using its dark theme.Light, of type object, that you set to the resource to be used when the device is using its light theme.Default, of type object, that you set to the resource to be used by default.The AppThemeBinding markup extension is supported by the AppThemeBindingExtension class, which defines the following properties: 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.
0 Comments
Leave a Reply. |