An example of the implementation of "multibinding + converter" is one of the options specified by @vitidev.
<!-- Где-нибудь в ресурсах --> <local:IntToBoolMultiConverter x:Key="IntToBoolMultiConverter"/> ... <Button Content="Test" Width="100"> <Button.IsEnabled> <MultiBinding Converter="{StaticResource IntToBoolMultiConverter}"> <Binding ElementName="SearchString1" Path="Text.Length"/> <Binding ElementName="SearchString2" Path="Text.Length"/> <Binding ElementName="SearchString3" Path="Text.Length"/> </MultiBinding> </Button.IsEnabled> </Button>
And the converter itself:
[ValueConversion(typeof(int[]), typeof(bool))] public class IntToBoolMultiConverter : IMultiValueConverter { public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { var result = values != null && values.All(x => x is int && (int)x != 0); return result; } public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) { throw new NotImplementedException(); } }
Although, the task of the converter (true if there are no zeros) is not quite obvious by this name and it is better to give it a more specific name.
But in general, I agree with @AlexKrass - here all the same, not some kind of margin or color change, but the inclusion / disabling of the functionality, and it is better to do this through the view model.