Share via


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

<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 を指定する必要があります (ターゲット要素とプロパティを明示的に指定したドット構文)。

適用対象