Binding Class |
Namespace: Windows.UI.Xaml.Data
[ContentPropertyAttribute("Path")] public class Binding : BindingBase
The Binding type exposes the following members.
Name | Description | |
---|---|---|
Binding |
Initializes a new instance of the Binding class.
| |
Binding(String) |
Initializes a new instance of the Binding class with the given path.
|
Name | Description | |
---|---|---|
Equals(Object) | (Inherited from Object.) | |
GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |
ProvideValue |
When implemented in a derived class, returns an object that is provided as
the value of the target property for this markup extension.
(Inherited from MarkupExtension.) | |
ToString | Returns a string that represents the current object. (Inherited from Object.) |
Name | Description | |
---|---|---|
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.
| |
ConverterLanguage |
Gets or sets a value that names the language to pass to any converter specified
by the Converter property.
Returns a string that names a language. Interpretation of this value is ultimately up to the converter logic.
| |
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.
| |
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.
| |
Mode |
Gets or sets a value that indicates the direction of the data flow in the binding.
Returns one of the BindingMode values.
| |
Path |
Gets or sets the path to the binding source property.
Returns the property path for the source of the binding.
| |
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.
| |
Source |
Gets or sets the data source for the binding.
Returns the source object that contains the data for the binding.
|
MyTextBlock.DataContext = myPlanet;
<TextBlock x:Name="MyTextBlock" Text="{Binding Size}" HorizontalAlignment="Left" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" />
Binding myBinding = new Binding("Size"); MyTextBlock.SetBinding(TextBlock.TextProperty, myBinding); MyTextBlock.DataContext = myPlanet;
MyTextBox.DataContext = myPlanet;
<Border> <!-- We define the Converter: --> <Border.Resources> <local:KilometersToMilesConverter x:Key="KilometersToMilesConverter" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:MyAssembly.MyApp" /> </Border.Resources> <TextBox x:Name="MyTextBox" Text="{Binding Length, Mode=TwoWay, Converter={StaticResource KilometersToMilesConverter}}" HorizontalAlignment="Left" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" /> </Border>
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;