There is a datatrigger style:

  1. Is it possible to change a date on a date like that value in the course of the program? Now he writes that the trigger after use becomes sealed. And you can not change it. Those. Now I am rebuilding the whole style again, and this is a lot of code. Especially when in the style of a lot of triggers and setters.
  2. How to quickly copy the base style? Now I run for TriggerCollection and for the setters collections, again this is a bunch of code ((and then I use it on the item I need).
  • You do something wrong, this kind of balancing act is usually not needed. Tell us what you want to achieve with this, what your real problem is. - VladD
  • There is a value, a certain amount of the date column of date grid 1. It is compared with the standard and depending on the result I crash the data grid cell 2. Data grid 2 is one line with the totals. For example, the amount in the column is 3 - green. Then the lines in data grid 1 are added and removed, and this ideal value (3) can change. And now the triple will be not green, but yellow to give out, but green 3.5 will be admitted. - Chelios
  • one
    This is similar to business logic, I would not encode it at all with triggers, but delivered it to a VM. - VladD

1 answer 1

As for the first question - as an option, you can use a certain MultiValueConverter in the Binding DataTrigger so that it takes the current Binding and Value as values ​​and compares them.

<DataTrigger Value="True"> <DataTrigger.Binding> <MultiBinding Converter="{StaticResource EqualToBooleanConverter}"> <Binding Path="CurrentValue" /> <Binding Path="RequiredValue" /> </MultiBinding> </DataTrigger.Binding> </DataTrigger> 

MultiValueConverter itself, for example, might look something like this:

 public class EqualToBooleanConverter : IMultiValueConverter { public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { return values.Length > 1 && values.Skip(1).All(x => Equals(values[0], x)); } public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) { throw new NotSupportedException(); } } 
  • An interesting solution, I will try. - Chelios