From the course: Xamarin.Forms Essential Training

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Trigger a style by property value

Trigger a style by property value - Xamarin Tutorial

From the course: Xamarin.Forms Essential Training

Start my 1-month free trial

Trigger a style by property value

- [Male Voice] There are going to be situations where you don't want the style to apply all the time. Let's get a little more real estate here and so if we look at our style, you may not want to have that background color red all the time, only when there's some sort of an error condition. So lets do style.triggers, and now we can add a trigger in here. We're going to be able to define what's going to trigger the style to get applied. So again we'll use that TargetType, we'll use entry, then we want to use the particular value, so what value is it that's going to trigger this, and we'll say that if you have a zero in the quantity, that's going to be a trigger for us and so we to specify the property as text to indicate that's the property on the entry that we're looking at, and if that value is zero, then we want to go ahead and trigger this. Now inside the trigger, we'll just copy the setter, or rather cut and paste that in. We'll…

Contents