PlatformThemeSettings Class
Tracks theme preferences shared by visuals with the same platform settings source.
public sealed class PlatformThemeSettings
- Inheritance:
- object object
Remarks
Access this type on the UI thread. Resolve settings with GetFor(Visual) after a visual is attached to a visual tree, subscribe to ColorValuesChanged, and read the current properties. Unsubscribe on detachment and resolve settings again on reattachment, since the platform source may change. The platform subscription exists only while there are consumers. Settings describe platform preferences, independently of the theme variant applied to a control.
Properties
IsHighContrast
Indicates whether the platform prefers high-contrast presentation.
public bool IsHighContrast { get; }
Property Value
Remarks
Call on the UI thread. When no consumers subscribe to ColorValuesChanged, reading this property queries the platform to keep retained instances current.
Methods
GetFor(Visual)
Returns the shared theme preferences for a visual's platform settings source.
public static PlatformThemeSettings? GetFor(Visual visual)
| Parameter | Type | Description |
|---|---|---|
| visual | Visual | The visual to examine. |
Returns
- PlatformThemeSettings:
The shared settings, or
nullif the visual has no platform settings source.
Remarks
Call on the UI thread. Detached visuals normally have no platform settings source. Visuals with the same platform settings source share an instance.
Events
ColorValuesChanged
Occurs on the UI thread when an exposed platform color preference changes.
public event EventHandler? ColorValuesChanged
Event Type
Remarks
All affected properties are updated before this event is raised. Currently, only changes to IsHighContrast raise this event. Subscribing does not raise an initial notification; read the current properties after subscribing.
Inherited Members
- object.GetType()
- object.ToString()
- object.Equals(object)
- object.Equals(object, object)
- object.ReferenceEquals(object, object)
- object.GetHashCode()