Styles and themes
Reuse typed property sets and apply implicit styles across an application.
Style<T> is a named block of setters for one view type:
Assign it through View.Style. Put the style first in an object initializer because assignments run in source order:
The later local
CornerRadiusoverrides the style. AssigningStylelast would apply all its setters over earlier values.
Style inheritance
A style can build on another compatible style:
The base style runs first, then the derived setters. The base target must be assignable from the derived target; a style for an unrelated control cannot be applied.
Implicit themes
Register application-wide styles during startup:
When a view is constructed, the theme applies matching styles from base types to the concrete type. A Style<View> can establish shared defaults, then a Style<Button> or Style<Border> can refine them.
Explicit styles and local initializer values run after the constructor, so they override the implicit theme. A theme is frozen when the app begins using it and cannot be changed later. Use bindable colors, appearance changes, or explicit state updates for runtime theming rather than trying to register another theme.
Styles execute normal C# setters. They do not create a separate property-value layer, and changing the Style<T> object later does not revisit existing views.