Get the App
SLTechnology News&Howtos  ›  Development  › 

How WPF uses MultiConverter to control Button status

Shulou Source: shulou.com Published: 2022-06-03 07:40:55 11月15日 Update

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

Tags: Status content control articles code buttons data data sources learning help differences elegance rudeness functions just multiple feelings solutions easy to understand more Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS OPPO Reno Redmi Microsoft MySQL