[ACCEPTED]-WPF Trigger when property value is greater than a certain amount-triggers
You can use a data trigger and set the binding 2 RelativeSource to Self. Data Triggers allow 1 binding and bindings lets you have converters.
Example:
<Button Content="I change colour depending on my width for some reason">
<Button.Triggers>
<DataTrigger
Binding="{Binding
Path=Width,
RelativeSource={RelativeSource Self},
Converter={StaticResource isLessThanConverter},
ConverterParameter=50}"
Value="True">
<Setter Property="Button.Background" Value="Red" />
DataTrigger>
Button.Triggers>
Button>
Not without code behind. Usual practice 1 is:
- When working with UI elements, create an IValueConverter and bind to the property using the converter.
- When working with bound data, create a bool property on your data and trigger from that property.
Something might have been added in SP1, but 6 the way I've achieved this in the past is 5 with a ValueConvertor that converts the 4 value into a boolean.
In your example your 3 convertor would return true if the value 2 was > 25, false otherwise. If that doesn't 1 make sense I can put an example up :-)
Data Trigger only validates exact value, not 3 validates "evaluated values"(like greater 2 than, less than, addition etc.). you need 1 a converter to convert to exact value.
More Related questions
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.