共用方式為


Label.Target Property

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Gets or sets the control that this Label is associated with.

Namespace:  System.Windows.Controls
Assembly:  System.Windows.Controls.Data.Input (in System.Windows.Controls.Data.Input.dll)

Syntax

'Declaration
Public Property Target As FrameworkElement
public FrameworkElement Target { get; set; }
<sdk:Label Target="{Binding ElementName=targetElementName}"/>

XAML Values

  • targetElementName
    The name of a UIElement that the Label is associated with.

Property Value

Type: System.Windows.FrameworkElement
The control that this Label is associated with.

Remarks

Dependency property identifier field: TargetProperty

You associate a Label with another control by setting the Target property. The Target is a reference to a UIElement. You can set the Target in code or in XAML. To set it in XAML, you must use an ElementName binding.

When the Target property is set, a Label inspects each DependencyProperty on the Target control for a Binding. For each Binding that is found, it inspects the Source of the Binding for metadata. The metadata can be used to set the caption text, specify whether the field is required, and specify validation rules. If the Target control has more than one Binding, you can specify the one to retrieve metadata from by setting the PropertyPath property.

Version Information

Silverlight

Supported in: 5, 4, 3

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.