Partager via


Binding.Mode Property

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Gets or sets a value that indicates the direction of the data flow in the binding.

Namespace:  System.Windows.Data
Assembly:  System.Windows (in System.Windows.dll)

Syntax

'Declaration
Public Property Mode As BindingMode
public BindingMode Mode { get; set; }
<Binding Mode="bindingModeMemberName"/>

Property Value

Type: System.Windows.Data.BindingMode
One of the BindingMode values. The default is BindingMode.OneWay.

Exceptions

Exception Condition
InvalidOperationException

The Binding has already been attached to a target element, and cannot be modified.

Remarks

In OneWay or TwoWay bindings, the source object must implement INotifyPropertyChanged in order for the target to update when the source changes.

See Binding Markup Extension to learn how Mode can be set as a binding property through the Binding markup extension, which enables specifying an entire Binding as an attribute string.

Examples

The following example demonstrates how to set the binding mode in XAML.

<TextBox x:Name="MyTextBox" Text="Text" Foreground="{Binding Brush1, Mode=OneWay}"/>

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

See Also

Reference

Other Resources