RelativeSource.Self Property
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets a static value that is used to return a RelativeSource constructed for the Self mode.
public:
static property System::Windows::Data::RelativeSource ^ Self { System::Windows::Data::RelativeSource ^ get(); };
public static System.Windows.Data.RelativeSource Self { get; }
static member Self : System.Windows.Data.RelativeSource
Public Shared ReadOnly Property Self As RelativeSource
A static RelativeSource.
The following example shows a style trigger that creates a ToolTip that reports a validation error message. The value of the setter binds to the error content of the current TextBox (the TextBox using the style) using the RelativeSource property. See How to: Implement Binding Validation for more information on this example.
<Style x:Key="textBoxInError" TargetType="{x:Type TextBox}">
<Style.Triggers>
<Trigger Property="Validation.HasError" Value="true">
<Setter Property="ToolTip"
Value="{Binding RelativeSource={x:Static RelativeSource.Self},
Path=(Validation.Errors)/ErrorContent}"/>
</Trigger>
</Style.Triggers>
</Style>
Three of the four RelativeSourceMode values, PreviousData, Self, or TemplatedParent, can produce a RelativeSource that is wholly static, containing no unique private values. All uses of the static property can share the same object, eliminating the need to allocate separate objects for each use. Therefore, using the static property reduces memory usage.
For XAML information, see RelativeSource MarkupExtension.
Product | Versions |
---|---|
.NET Framework | 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
Windows Desktop | 3.0, 3.1, 5, 6, 7, 8, 9 |
.NET feedback
.NET is an open source project. Select a link to provide feedback: