From the course: .NET MAUI Essential Training

Unlock the full course today

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

Using triggers to apply styles

Using triggers to apply styles - .NET MAUI Tutorial

From the course: .NET MAUI Essential Training

Using triggers to apply styles

- [Instructor] Let's go back up to our Entry here. Remember that we created not only the default Entry that we had here but a new Entry where we had a Key for numberEntry. But, in this case, if we have an Entry and it uses this Key, all these styles are going to get applied, and we might want to actually apply them a little more discriminately. We might want to have some sort of a Trigger that indicates when a style should be applied. So, if I enter Style.Triggers, now I can come in and put a Trigger in here. I can say the TargetType, again, is Entry 'cause that's how this applies. I want to check for the Value being equal to 0. In our case, on our numeric entries here, the Value 0, we're going to want to change the background to red. So I've got the Value, and then I've got the Property of Text. So, if Text equals 0, what do we want to do? And now we put a Setter in here. So we have a Setter, we have that Property…

Contents