Managing Visual State
Every VisualElement
has a Visual State at any given moment (for example, does VisualElement
have focus? Is it selected?). You can imagine responding to that state programmatically in C#, but there are advantages to responding to changes in visual state declaratively, in the XAML. Doing so puts more of the UI management in one place – your view (for example, MainPage.xaml
).
VisualElement
VisualElement
is the base class of all controls (and pages).
The object that sets visual properties on VisualElement
based on its state is the Visual State Manager. The Visual State Manager selects from among a set of VisualStates
and displays a VisualElement
according to the properties set in the XAML.
This forces the question: what are visual states?
Defining the common visual states
.NET MAUI defines a set of common visual states:
Normal
Disabled
Has focus
Is selected
Mouse over
(for Windows and macOS)
.NET MAUI also allows...