Comparable DataTriggers in WPF
Do you work with databindings in WPF and find that you have ever wanted to do this??
<DataTrigger Binding="{l:ComparisonBinding Age, LT, 65}" Value="{x:Null}" >
One of the most requested WPF features is the ability to do comparisons in a databinding. Over at Mike Hillberg's Blog he has written a nice piece of code that allows you to do this and it's a great add-on..
quoting his blog:
" The basics:
· You have to set the DataTrigger.Value to null. That’s the main hack.
· The supported comparison operators are GT, GTE, LT, LTE, and EQ.
· The comparand (“65” in the example) is converted from string to the type of the target value (presumably Age is an int in the above example), using Compare.ChangeType or the target’s TypeConverter."



