Here’s my textblock.
<Image x:Name:imgAnother/>
<TextBlock>
this is my text block
<TextBlock.Style>
<Style TargetType="TextBlock">
<Setter Property="TextDecorations" Value="None"/>
<Style.Triggers>
<Trigger Property="TextBlock.IsMouseOver" Value="True">
<Setter Property="Foreground" Value="RoyalBlue"/>
<!--I like to insert a code at here that changes another control's property...-->
</Trigger>
<Trigger Property="TextBlock.IsMouseOver" Value="False">
<Setter Property="Foreground" Value="#FF808080"/>
<!--..and this line too.-->
</Trigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
I like to make a xaml code which can change another control’s proerpty, like “imgAnother”.
how can i do that?
You must aggregate the source and the target in some way.
You may create either a custom control containing both the hyperlink/textblock and the image. That’s the preferred way if you have several blocks that behaves in such example.
If you don’t like this. You may create a “temporary” anonymous control as follows:
The above xaml will reside in your Window’s resources.
NOTE: it’s much like a track to follow, than a fully functional snippet!
In the body, you may refer the control in such manner:
Hope it helps.