Class Binding
Defines a binding that connects the properties of binding targets and data sources.
Implements
Inherited Members
Namespace: System.Windows.Data
Assembly: OpenSilver.dll
Syntax
public class Binding : BindingBase, IMarkupExtension<object>
Examples
You can add a Binding using XAML as follows:
MyTextBlock.DataContext = myPlanet;
Note: you can create the Binding directly using C#:
Binding myBinding = new Binding("Size");
MyTextBlock.SetBinding(TextBlock.TextProperty, myBinding);
MyTextBlock.DataContext = myPlanet;
Here is another example using the TwoWay mode, and also using a Converter:
MyTextBox.DataContext = myPlanet;
Using C#:
Binding myBinding = new Binding("Size");
//we set the binding in TwoWay mode:
myBinding.Mode = BindingMode.TwoWay;
//We create the converter:
myBinding.Converter = new KilometersToMilesConverter();
MyTextBox.SetBinding(TextBox.TextProperty, myBinding);
MyTextBox.DataContext = myPlanet;
Constructors
| Improve this Doc View SourceBinding()
Initializes a new instance of the Binding class.
Declaration
public Binding()
Binding(String)
Initializes a new instance of the Binding class with an initial property path for the data source.
Declaration
public Binding(string path)
Parameters
Type | Name | Description |
---|---|---|
System. |
path | The initial property path for the source of the binding. |
Exceptions
Type | Condition |
---|---|
System. |
path is null. |
Binding(Binding)
Initializes a new instance of the Binding class with initial property values copied from the specified Binding.
Declaration
public Binding(Binding original)
Parameters
Fields
| Improve this Doc View SourceIsDebuggingEnabled
Indicates whether data binding debugging is enabled.
Declaration
[NotImplemented]
public static bool IsDebuggingEnabled
Field Value
Type | Description |
---|---|
System. |
Properties
| Improve this Doc View SourceBindsDirectlyToSource
Gets or sets a value that indicates whether the binding ignores any ICollection
Declaration
public bool BindsDirectlyToSource { get; set; }
Property Value
Type | Description |
---|---|
System. |
true if the binding binds directly to the data source; otherwise, false. |
Converter
Gets or sets the converter object that is called by the binding engine to modify the data as it is passed between the source and target, or vice versa.
Declaration
public IValueConverter Converter { get; set; }
Property Value
Type | Description |
---|---|
IValue |
The IValue |
ConverterCulture
Gets or sets the culture to be used by the Converter.
Declaration
public CultureInfo ConverterCulture { get; set; }
Property Value
Type | Description |
---|---|
System. |
The System. |
ConverterParameter
Gets or sets a parameter that can be used in the Converter logic.
Declaration
public object ConverterParameter { get; set; }
Property Value
Type | Description |
---|---|
System. |
A parameter to be passed to the Converter. This can be used in the conversion logic. The default is null. |
ElementName
Gets or sets the name of the element to use as the binding source object.
Declaration
public string ElementName { get; set; }
Property Value
Type | Description |
---|---|
System. |
The value of the Name property or x:Name Attribute of the element to bind to. The default is null. |
Mode
Gets or sets a value that indicates the direction of the data flow in the binding.
Declaration
public BindingMode Mode { get; set; }
Property Value
Type | Description |
---|---|
Binding |
One of the Binding |
NotifyOnValidationError
Gets or sets a value that indicates whether the Binding
Declaration
public bool NotifyOnValidationError { get; set; }
Property Value
Type | Description |
---|---|
System. |
true if the Binding |
Path
Gets or sets the path to the binding source property.
Declaration
public PropertyPath Path { get; set; }
Property Value
Type | Description |
---|---|
Property |
The property path for the source of the binding. See Property |
RelativeSource
Gets or sets the binding source by specifying its location relative to the position of the binding target.
Declaration
public RelativeSource RelativeSource { get; set; }
Property Value
Type | Description |
---|---|
Relative |
The relative location of the binding source to use. The default is null. |
Source
Gets or sets the data source for the binding.
Declaration
public object Source { get; set; }
Property Value
Type | Description |
---|---|
System. |
The source object that contains the data for the binding. |
UpdateSourceTrigger
Gets or sets a value that determines the timing of binding source updates for two-way bindings.
Declaration
public UpdateSourceTrigger UpdateSourceTrigger { get; set; }
Property Value
Type | Description |
---|---|
Update |
A value that determines when the binding source is updated. The default is Default. |
ValidatesOnDataErrors
Gets or sets a value that indicates whether the binding engine will report validation
errors from an System.
Declaration
public bool ValidatesOnDataErrors { get; set; }
Property Value
Type | Description |
---|---|
System. |
true if the binding engine will report System. |
ValidatesOnExceptions
Gets or sets a value that indicates whether the binding engine will report exception validation errors.
Declaration
public bool ValidatesOnExceptions { get; set; }
Property Value
Type | Description |
---|---|
System. |
true if the binding engine will report exception validation errors; otherwise, false. The default is false. |
ValidatesOnNotifyDataErrors
Gets or sets a value that indicates whether the binding engine will report validation
errors from an System.
Declaration
public bool ValidatesOnNotifyDataErrors { get; set; }
Property Value
Type | Description |
---|---|
System. |
true if the binding engine will report System. |