Label.Target Property
Gets or sets the element that receives focus when the user presses the label's access key.
Assembly: PresentationFramework (in PresentationFramework.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation
[TypeConverterAttribute(typeof(NameReferenceConverter))] public UIElement Target { get; set; }
<Label Target="nameOfExistingElement"/>
XAML Values
Property Value
Type: System.Windows.UIElementThe UIElement that receives focus when the user presses the access key. The default is null.
You can provide keyboard shortcuts to elements that don't support access keys by giving a Label an access key and setting this property. Assign an access key to a label by placing an underscore immediately before the character that acts as the access key. An access key can be specified in the Content property or by setting Content to an AccessText object.
You cannot use this property to define a UIElement. For example, the following compiles but is not functional: <object.Target><UIElement../></object.Target>. This property provides a reference to an element that is already defined in your application.
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
The example in the topic is correct if you target WPF 4.
You can also use the x:Reference markup extension in WPF 4.
<Label Target="{x:Reference tb}">_File</Label>
If you use an earlier version of WPF, you need to use binding:
<Label Target="{Binding ElementName=tb}">_File</Label>
- 9/21/2010
- Carole Snyder - MSFT
<TextBox x:Name="surnameTextBox" />
- 9/16/2010
- Shimmy Weitzhandler
<Label Target="{Binding ElementName=tb}">_File</Label>
- 8/26/2010
- Contessa Mary