Binding.RelativeSource Property
[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]
Gets or sets the binding source by specifying its location relative to the position of the binding target.
Assembly: System.Windows (in System.Windows.dll)
XMLNS for XAML: Not mapped to an xmlns.
<Binding RelativeSource="{RelativeSource TemplatedParent}"/> -or- <Binding RelativeSource="{RelativeSource Self}"/>
XAML Values
Property Value
Type: System.Windows.Data.RelativeSourceThe relative location of the binding source to use. The default is Nothing.
| Exception | Condition |
|---|---|
| InvalidOperationException | The Binding has already been attached to a target element, and cannot be modified. -or- The ElementName or Source property has already been set. |
Source, RelativeSource, and ElementName are mutually exclusive in a binding. If you have set one of these attributes, then setting either of the other two in a binding (through XAML or through code) will cause an exception.
Setting RelativeSource in XAML always requires the use of theRelativeSource markup extension.