Binding.RelativeSource property

This topic has not yet been rated - Rate this topic

Gets or sets the binding source by specifying its location relative to the position of the binding target.

Syntax


public RelativeSource RelativeSource { get; set; }


<Binding RelativeSource="{RelativeSource TemplatedParent}"/>
-or-
<Binding RelativeSource="{RelativeSource Self}"/>


XAML Values

{RelativeSource TemplatedParent}

The control where a ControlTemplate is applied is the source for this binding. This is useful for applying validation error information in bindings at the template level.

{RelativeSource Self}

The target element should be used as the source for this binding. This is useful for binding one property of an element to another property on the same element.

Property value

Type: RelativeSource

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

Remarks

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 the RelativeSource markup extension. This is also true if you are creating the entire binding as a Binding markup extension, in which case the RelativeSource markup extension is nested within the RelativeSource component of the expression.

Requirements

Minimum supported client

Windows 8

Minimum supported server

Windows Server 2012

Namespace

Windows.UI.Xaml.Data
Windows::UI::Xaml::Data [C++]

Metadata

Windows.winmd

See also

Binding
XAML data binding sample
Data binding overview

 

 

Build date: 12/4/2012

Did you find this helpful?
(1500 characters remaining)
© 2013 Microsoft. All rights reserved.