Setter.Target Properti
Definisi
Penting
Beberapa informasi terkait produk prarilis yang dapat diubah secara signifikan sebelum dirilis. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
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
Nilai Properti
Jalur properti pada elemen target untuk menerapkan Nilai .
Contoh
Contoh ini memperlihatkan cara menggunakan beberapa pernyataan Setter di dalam properti VisualState.Setters untuk menerapkan perubahan nilai properti diskrit pada berbagai elemen (tanpa animasi) saat VisualState diterapkan.
<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>
Untuk memperbarui nilai properti terlampir, tempatkan jalur properti terlampir di dalam tanda kurung. Contoh ini menunjukkan cara memperbarui RelativePanel.AlignRightWithPanel
nilai pada elemen dengan nama 'TitleTextBlock'.
<RelativePanel>
<TextBlock x:Name="TitleTextBlock" Text="Title"/>
</RelativePanel>
...
<Setter Target="TitleTextBlock.(RelativePanel.AlignRightWithPanel)" Value="True"/>
Keterangan
Properti Setter.Target dapat digunakan dalam Gaya atau VisualState, tetapi dengan cara yang berbeda.
- Saat digunakan dalam Gaya, properti yang perlu dimodifikasi dapat ditentukan secara langsung.
- Saat digunakan dalam VisualState, properti Target harus diberi TargetPropertyPath (sintaks putus-putus dengan elemen target dan properti yang ditentukan secara eksplisit).