wpf xaml 中的计算绑定不用convert

Key features and restrictions:

  1. One or many source properties in Path with many available operators: description
<Label Content="{c:Binding A*0.5+(B.NestedProp1/C - B.NestedProp2 % C) }" />
<c:Binding 'A and B or C' />
  1. One or many static properties in Path: description
<TextBox Text="{c:Binding 'local:StaticClass.Prop1 + local:OtherStaticClass.NestedProp.PropB + PropC'}"/>
<Button Background="{c:Binding '(A > B ? media:Brushes.LightBlue : media:Brushes.White)'}"/>
  1. Properties and methods of class System.Math in Path: description
<TextBox Text="{c:Binding 'Math.Sin(Math.Cos(A))'}"/>
  1. Enum types like constants or source properties in Path: description
<TextBox Text="{c:Binding '(EnumValue == local:CustomEnum.Value1 ? 10 : 20)'}"/>
  1. Automatic inversion of binding expression if it's possible: description
<TextBox Text = "{c:Binding 'Math.Sin(A*2)-5'}"/> {two way binding will be created}
  1. Automatic two way convertion of bool expression to Visibility and back if target property has such type: description
<Button Visibility="{c:Binding !IsChecked}" /> 
<Button Visibility="{c:Binding IsChecked, FalseToVisibility=Hidden}" />
  1. Other features such as string and char constants support and other: description

  2. General restrictions: description

 

GitHub - Alex141/CalcBinding: Advanced WPF Binding which supports expressions in Path property and other features

 

快速使用:PM> Install-Package CalcBinding 

xmlns:c="clr-namespace:CalcBinding;assembly=CalcBinding"

<Label IsEnabled="{c:Binding Path=!fullFill}" />   

posted on 2022-06-22 11:14  空明流光  阅读(437)  评论(0编辑  收藏  举报

导航