[]
A C1.WPF.Binding that supports formulas.
public class C1Binding : MarkupExtension, IValueConverter
<p>The <b>C1Binding</b> class is similar to a regular <xref href="C1.WPF.Binding" data-throw-if-not-resolved="false"></xref>,
but supports expressions instead of simple paths.
The expression syntax is similar to the one used in Excel formulas, including support for the IF statement which makes it easy to create bindings that make Converters unnecessary.
The XAML below uses the C1Binding class to bind several properties of a TextBlock element to a data value. Notice that the bindings are used to provide values for properties of several types, and no converters are required.
<TextBlock
Text="{c1:C1Binding Expression=CustomerName}"
Visibility="{c1:C1Binding Expression='if(Active, |Visible|, |Collapsed|)'}"
FontWeight="{c1:C1Binding Expression='if(Sales > 200, |Bold|, |Normal|)'}"
Foreground="{c1:C1Binding Expression='if(Sales > 200, |Blue|, |Red|)'}" />
Notice how the XAML snippet above specifies the 'Expression' property. This is required only in Silverlight, and could be omitted in WPF. Notice also how vertical bars ('|') are used to specify quotes inside expressions. You could also use " instead, but the bars made the code more readable.
Name | Description |
---|---|
C1Binding() | Initializes a new instance of a C1Binding. |
C1Binding(string) | Initializes a new instance of a C1Binding. |
Name | Description |
---|---|
Expression | Gets or sets the expression used to calculate the binding value. |
FallbackValue | Gets or sets the value to use when the binding is unable to return a value. |
StringFormat | Gets or sets a string that specifies how to format the binding value. |
TargetNullValue | Gets or sets the value that is used in the target when the value of the source is null. |
Name | Description |
---|---|
ProvideValue(IServiceProvider) | Returns an object that is provided as the value of the target property for this markup extension. |