BoolExpressionConverter en - Leksiqq/WpfMarkupExtension GitHub Wiki

BoolExpressionConverter class

incomplete implementation of the IMultiValueConverter interface, which implements the object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) method, which is passed an array of bool values values and a string describing the Boolean expression above them, as parameter. Returns the result of evaluating an expression.

Methods

object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) - evaluates the expression passed in the parameter line, in which the operands are the elements of the values array. The expression string uses the operators !, & and |. Literals of the form @n are used as operands, where n is the position of the corresponding element of the values array, starting from zero. The expression must be a valid parenthesis sequence.

Example

     <Style x:Key="ButtonVisibleIfCanEdit" TargetType="ButtonBase">
         <Style.Triggers>
             <l:DataSwitch>
                 <l:DataSwitch.Binding>
                     <MultiBinding Converter="{StaticResource BoolExpressionConverter}"
                         ConverterParameter="@0 | @1">
                         <Binding Path="Value" Converter="{StaticResource IsNullConverter}"/>
                         <Binding Path="IsReadonly"/>
                     </MultiBinding>
                 </l:DataSwitch.Binding>
                 <DataTrigger Value="True">
                     <Setter Property="Visibility" Value="Collapsed"/>
                 </DataTrigger>
                 <DataTrigger Value="False">
                     <Setter Property="Visibility" Value="Visible"/>
                 </DataTrigger>
             </l:DataSwitch>
         </Style.Triggers>
     </Style>

Before: (DataSwitch) Start:(Overview) Next:(ConverterProxy)

⚠️ **GitHub.com Fallback** ⚠️