Setter.Target プロパティ

定義

Value を適用するターゲット要素のプロパティのパスを取得または設定します。

public:
 property TargetPropertyPath ^ Target { TargetPropertyPath ^ get(); void set(TargetPropertyPath ^ value); };
TargetPropertyPath Target();

void Target(TargetPropertyPath value);
public TargetPropertyPath Target { get; set; }
var targetPropertyPath = setter.target;
setter.target = targetPropertyPath;
Public Property Target As TargetPropertyPath

プロパティ値

Value を適用するターゲット要素のプロパティのパス。

この例では、 VisualState を適用するときに、VisualState.Setters プロパティ内で複数の Setter ステートメントを使用して、さまざまな要素 (アニメーションなし) に個別のプロパティ値の変更を適用する方法 示します。

<Page>
    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
        <VisualStateManager.VisualStateGroups>
            <VisualStateGroup>
                <VisualState x:Name="NarrowState">
                    <VisualState.Setters>
                        <Setter Target="myPanel.Orientation" Value="Vertical"/>
                        <Setter Target="myPanel.Width" Value="380"/>
                        <Setter Target="myTextBlock.MaxLines" Value="3"/>
                    </VisualState.Setters>
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>

        <StackPanel x:Name="myPanel" Orientation="Horizontal">
            <TextBlock x:Name="myTextBlock" MaxLines="5" Style="{ThemeResource BodyTextBlockStyle}"/>
        </StackPanel>
    </Grid>
</Page>

添付プロパティの値を更新するには、添付プロパティ パスをかっこ内に配置します。 この例では、"TitleTextBlock" という名前の要素の値を更新 RelativePanel.AlignRightWithPanel する方法を示します。

<RelativePanel>
    <TextBlock x:Name="TitleTextBlock" Text="Title"/>
</RelativePanel>

...

<Setter Target="TitleTextBlock.(RelativePanel.AlignRightWithPanel)" Value="True"/>

注釈

Setter.Target プロパティは、Style または VisualState のいずれかで使用できますが、さまざまな方法で使用できます。

  • Style で使用する場合は、変更する必要があるプロパティを直接指定できます。
  • VisualState で使用する場合、Target プロパティには TargetPropertyPath (ターゲット要素とプロパティを明示的に指定したドット構文) を指定する必要があります。

適用対象