<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也应该触发了,但是无效,有谁知道原因?