共用方式為


Setter.TargetName 屬性

定義

取得或設定這個 Setter 適用的物件名稱。

public:
 property System::String ^ TargetName { System::String ^ get(); void set(System::String ^ value); };
public string TargetName { get; set; }
[System.Windows.Markup.Ambient]
public string TargetName { get; set; }
member this.TargetName : string with get, set
[<System.Windows.Markup.Ambient>]
member this.TargetName : string with get, set
Public Property TargetName As String

屬性值

String

預設值是 null

屬性

範例

在下列範例中, TargetName 會用於觸發程式 Setter ,以指定 Setter 用於 Ellipse 內具名 ThumbCoverControlTemplate

<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>

備註

您可以將此屬性設定為 setter 集合 (套用) 集合之集合範圍內的任何專案名稱。 這通常是包含此 setter 之範本內的具名專案。

適用於

另請參閱