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.String | path | The initial property path for the source of the binding. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | 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
Type | Name | Description |
---|---|---|
Binding | original | The Binding to copy. |
Fields
| Improve this Doc View SourceIsDebuggingEnabled
Declaration
[NotImplemented]
public static bool IsDebuggingEnabled
Field Value
Type | Description |
---|---|
System.Boolean |
Properties
| Improve this Doc View SourceBindsDirectlyToSource
Gets or sets a value that indicates whether the binding ignores any ICollectionView settings on the data source.
Declaration
public bool BindsDirectlyToSource { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | 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. Returns the IValueConverter object that modifies the data.
Declaration
public IValueConverter Converter { get; set; }
Property Value
Type | Description |
---|---|
IValueConverter |
ConverterCulture
Gets or sets the culture to be used by the Binding.Converter. Returns the System.Globalization.CultureInfo used by the Binding.Converter.
Declaration
public CultureInfo ConverterCulture { get; set; }
Property Value
Type | Description |
---|---|
System.Globalization.CultureInfo |
ConverterParameter
Gets or sets a parameter that can be used in the Converter logic. Returns a parameter to be passed to the Converter. This can be used in the conversion logic. The default is null.
Declaration
public object ConverterParameter { get; set; }
Property Value
Type | Description |
---|---|
System.Object |
ElementName
Gets or sets the name of the element to use as the binding source for the Binding. Returns the value of the Name property or x:Name attribute for the element to bind to. The default is null.
Declaration
public string ElementName { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Mode
Gets or sets a value that indicates the direction of the data flow in the binding. Returns one of the BindingMode values.
Declaration
public BindingMode Mode { get; set; }
Property Value
Type | Description |
---|---|
BindingMode |
NotifyOnValidationError
Gets or sets a value that indicates whether the System.Windows.FrameworkElement.BindingValidationError event is raised on validation errors.
Declaration
public bool NotifyOnValidationError { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
Path
Gets or sets the path to the binding source property. Returns the property path for the source of the binding.
Declaration
public PropertyPath Path { get; set; }
Property Value
Type | Description |
---|---|
PropertyPath |
RelativeSource
Gets or sets the binding source by specifying its location relative to the position of the binding target. Returns the relative location of the binding source to use. The default is null.
Declaration
public RelativeSource RelativeSource { get; set; }
Property Value
Type | Description |
---|---|
RelativeSource |
Source
Gets or sets the data source for the binding. Returns the source object that contains the data for the binding.
Declaration
public object Source { get; set; }
Property Value
Type | Description |
---|---|
System.Object |
UpdateSourceTrigger
Update type
Declaration
public UpdateSourceTrigger UpdateSourceTrigger { get; set; }
Property Value
Type | Description |
---|---|
UpdateSourceTrigger |
ValidatesOnDataErrors
Gets or sets a value that indicates whether the binding engine will report validation errors from an System.ComponentModel.IDataErrorInfo implementation on the bound data entity.
Declaration
[NotImplemented]
public bool ValidatesOnDataErrors { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | true if the binding engine will report System.ComponentModel.IDataErrorInfo validation errors; otherwise, false. The default is false. |
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.Boolean |
ValidatesOnLoad
True to force the property to go through the Validation process when the Binding is set or when the Target is added in the Visual tree. This way, if the source property has an Invalid value when setting the Binding, it will immediately be marked as Invalid instead of waiting for a value change that keeps/makes it Invalid (which is what happens on Silverlight). Defaults to False since it is the behaviour of Silverlight and WPF.
Declaration
public bool ValidatesOnLoad { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
ValidatesOnNotifyDataErrors
Gets or sets a value that indicates whether the binding engine will report validation errors from an System.ComponentModel.INotifyDataErrorInfo implementation on the bound data entity.
Declaration
[NotImplemented]
public bool ValidatesOnNotifyDataErrors { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | true if the binding engine will report System.ComponentModel.INotifyDataErrorInfo validation errors; otherwise, false. The default is true. |