Export (0) Print
Expand All

Setter.TargetName Property

Gets or sets the name of the object this Setter is intended for.

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

[AmbientAttribute]
public string TargetName { get; set; }
<object TargetName="string" .../>

Property Value

Type: System.String
The default value is null.

You can set this property to the name of any element within the scope of where the setter collection (the collection that this setter is part of) is applied. This is typically a named element that is within the template that contains this setter.

In the following example, the TargetName is used for the trigger Setter to specify that the Setter is intended for the Ellipse named ThumbCover within the ControlTemplate.

		<Style x:Key="Slider_Thumb" TargetType="{x:Type Thumb}">
			<Setter Property="OverridesDefaultStyle" Value="true" />
			<Setter Property="Width" Value="14" />
			<Setter Property="Height" Value="14" />
			<Setter Property="Template">
				<Setter.Value>
					<ControlTemplate TargetType="{x:Type Thumb}">
						<Grid Width="14" Height="14">
							<Ellipse Fill="{TemplateBinding Foreground}" />
							<Ellipse Stroke="{TemplateBinding BorderBrush}" StrokeThickness="1" x:Name="ThumbCover" >
								<Ellipse.Fill>
									<LinearGradientBrush  EndPoint="0,1" StartPoint="0,0">
										<LinearGradientBrush.GradientStops>
											<GradientStop Color="#CCFFFFFF" Offset="0" />
											<GradientStop Color="#00000000" Offset=".5" />
											<GradientStop Color="#66000000" Offset="1" />
										</LinearGradientBrush.GradientStops>
									</LinearGradientBrush>
								</Ellipse.Fill>
							</Ellipse>
						</Grid>
						<ControlTemplate.Triggers>
							<Trigger Property="IsDragging" Value="true">
								<Setter TargetName="ThumbCover" Property="Fill">
									<Setter.Value>
										<LinearGradientBrush  EndPoint="0,1" StartPoint="0,0">
											<LinearGradientBrush.GradientStops>
												<GradientStop Color="#CCFFFFFF" Offset="1" />
												<GradientStop Color="#00000000" Offset=".5" />
												<GradientStop Color="#66000000" Offset="0" />
											</LinearGradientBrush.GradientStops>
										</LinearGradientBrush>
									</Setter.Value>
								</Setter>
							</Trigger>
						</ControlTemplate.Triggers>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
		</Style>

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

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

Show:
© 2014 Microsoft