How WPF uses MultiConverter to control Button status
This article mainly shows you "how WPF uses MultiConverter to control Button state". The content is simple and clear. I hope it can help you solve your doubts. Let me lead you to study and learn this article "how WPF uses MultiConverter to control Button state".
Requirement description
1. The state of the button needs to be judged by different combinations according to the contents of multiple data sources.
two。 The judgment rules for each data source can be customized.
Note: the following functions feel like a simple and rough implementation, if you know a more elegant solution, please let me know, thank you first!
Button XAML
The code is as follows:
MultiConverter judgment
The code is as follows:
Public class InvalidMultiValidationRuleToBooleanMultiConverter: IMultiValueConverter
{
# region IMultiValueConverter Members
Public object Convert (object [] values, Type targetType, object parameter, CultureInfo culture)
{
String [] paramlist = ((string) parameter) .split ('|')
If (paramlist = = null | | paramlist.Length