From the course: .NET MAUI: Beyond the Basics

Unlock the full course today

Join today to access over 24,800 courses taught by industry experts.

Custom view states

Custom view states

- [Instructor] Visual states allow properties to be changed on views in XML based on the state of the view. For example, a different background color could be shown on an entry view if it has focus versus when it doesn't. This allows us to have more control of the view in the XML presentation layer. Ideally, we would like to keep any such code out of the view models. One thing we can do is add new states that do not come by default with Maui. Perhaps you want to have an entry that has a different look and feel if the value in it is valid or not. In the start code for this video, we have a view model with a name property and in is valid method that is bound to an entry. So if we go under view models, we can see in the main view model there is an is name valid property, and a name property. And when the name property changes, it calls validate name, which sets whether or not the name is valid. We're going to start by…

Contents