<StackPanel Width="200"> <TextBox x:Name="TBS" Text="a" /> <TextBlock > <TextBlock.Style> <Style TargetType="TextBlock"> <Style.Triggers> <DataTrigger Binding="{Binding ElementName=TBS,Path=Text}" Value="a"> <Setter Property="Text" Value="Data Trigger is raised"></Setter> </DataTrigger> </Style.Triggers> </Style> </TextBlock.Style> </TextBlock> <Ellipse Width="100" Height="100" StrokeThickness="5" Stroke="Red"> <Ellipse.Style> <Style TargetType="Ellipse"> <Style.Triggers> <DataTrigger Binding="{Binding ElementName=TBS,Path=Text}" Value="a"> <Setter Property="Stroke" Value="Black"/> </DataTrigger> </Style.Triggers> </Style> </Ellipse.Style> </Ellipse> </StackPanel>
結果:
TextBlock的DataTrigger觸發了有效果,Ellipse的DataTrigger也應該觸發了,可是無效,有誰知道緣由?code