Label.Target Property

Gets or sets the element that receives focus when the user presses the label's access key. This is a dependency property.

Namespace:  System.Windows.Controls
Assembly:  PresentationFramework (in PresentationFramework.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation

public UIElement Target { get; set; }
<object>
  <object.Target>
    <UIElement .../>
  </object.Target>
</object>
<Label Target="{Binding ElementName=SomeName}"/>

XAML Values

SomeName

The name of UIElement that receives focus when the access key is pressed.

Property Value

Type: System.Windows.UIElement
The UIElement that receives focus when the user presses the access key. The default is null.

Identifier field

TargetProperty

Metadata properties set to true

None

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.

The following example shows how to set the Target property of a Label.

<TextBox Name="tb" Width="50"/>
<Label Target="{Binding ElementName=tb}">_File</Label>

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2015 Microsoft