Show / Hide Table of Contents

Class Binding

Defines a binding that connects the properties of binding targets and data sources.

Inheritance
System.Object
MarkupExtension
BindingBase
Binding
Implements
IMarkupExtension<System.Object>
Inherited Members
BindingBase._stringFormat
BindingBase.FallbackValue
BindingBase.TargetNullValue
BindingBase.StringFormat
BindingBase.CheckSealed()
BindingBase.ProvideValue(IServiceProvider)
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
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 Source

Binding()

Initializes a new instance of the Binding class.

Declaration
public Binding()
| Improve this Doc View Source

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.

| Improve this Doc View Source

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 Source

IsDebuggingEnabled

Indicates whether data binding debugging is enabled.

Declaration
[NotImplemented]
public static bool IsDebuggingEnabled
Field Value
Type Description
System.Boolean

Properties

| Improve this Doc View Source

BindsDirectlyToSource

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.

| Improve this Doc View Source

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
IValueConverter

The IValueConverter object that modifies the data.

| Improve this Doc View Source

ConverterCulture

Gets or sets the culture to be used by the Converter.

Declaration
public CultureInfo ConverterCulture { get; set; }
Property Value
Type Description
System.Globalization.CultureInfo

The System.Globalization.CultureInfo used by the Converter.

| Improve this Doc View Source

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.Object

A parameter to be passed to the Converter. This can be used in the conversion logic. The default is null.

| Improve this Doc View Source

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.String

The value of the Name property or x:Name Attribute of the element to bind to. The default is null.

| Improve this Doc View Source

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
BindingMode

One of the BindingMode values. The default is OneWay.

| Improve this Doc View Source

NotifyOnValidationError

Gets or sets a value that indicates whether the BindingValidationError event is raised on validation errors.

Declaration
public bool NotifyOnValidationError { get; set; }
Property Value
Type Description
System.Boolean

true if the BindingValidationError event is raised; otherwise, false. The default is false.

| Improve this Doc View Source

Path

Gets or sets the path to the binding source property.

Declaration
public PropertyPath Path { get; set; }
Property Value
Type Description
PropertyPath

The property path for the source of the binding. See PropertyPath.

| Improve this Doc View Source

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
RelativeSource

The relative location of the binding source to use. The default is null.

| Improve this Doc View Source

Source

Gets or sets the data source for the binding.

Declaration
public object Source { get; set; }
Property Value
Type Description
System.Object

The source object that contains the data for the binding.

| Improve this Doc View Source

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
UpdateSourceTrigger

A value that determines when the binding source is updated. The default is Default.

| Improve this Doc View Source

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
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.

| Improve this Doc View Source

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

true if the binding engine will report exception validation errors; otherwise, false. The default is false.

| Improve this Doc View Source

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
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.

Implements

IMarkupExtension<T>
  • Improve this Doc
  • View Source