A C1.Silverlight.Binding that supports formulas.

Namespace:  C1.Silverlight.Binding
Assembly:  C1.Silverlight.Binding.5 (in C1.Silverlight.Binding.5.dll)

Syntax

C#
public class C1Binding : MarkupExtension, IValueConverter
Visual Basic
Public Class C1Binding _
	Inherits MarkupExtension _
	Implements IValueConverter

Remarks

The C1Binding class is similar to a regular C1.Silverlight.Binding, 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.

Examples

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.
Copy CodeC#
<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 &quot; instead, but the bars made the code more readable.

Inheritance Hierarchy

System..::..Object
  System.Windows.Markup..::..MarkupExtension
    C1.Silverlight.Binding..::..C1Binding

See Also