ElementRule |
ElementRule allows definition of items through an explicit property Items.
< Rules > <ElementRule Items="{MultiBinding Source={Binding ItemId=Tube}, Filter=Conditional, FilterParameter=${Binding Contents.Water.Amount, Converter=GreaterThan, ConverterParameter=10}}"> <ApplyAction> <Setter Target="{Binding IsClickable}" Value="False" /> </Apply> <RevertAction> <Setter Target="{Binding IsClickable}" Value="True" /> </Revert> </ElementRule> </Rules>
Example above sets IsClickable property of every tube that has more than 10 water to false. Tube becomes a DataContext of ApplyAction and RevertAction, which is why its properties are accessible through a binding with a single property as a path. If any tube affected by the rule has some water removed and no longer satisfies filter condition, RevertAction is invoked.