我有一个包含图像和文本块的stackpanel。
TextBlock被绑定到一个样式,该样式使其闪烁,背景颜色从红色变为黑色,并交替显示为viceversa。
我想将TextBlock backgorund color绑定到stackpanel背景色,即当TextBlock背景色为红色时,需要stackpanel背景色为红色,当TextBlock背景色为黑色时,则stackpanel背景色必须更改为黑色,依此类推。。。
以下是我的代码:
<Border Visibility="{Binding Path=BlinkOn, Converter={StaticResource BoolToVis}}" BorderThickness="1" BorderBrush="Red" CornerRadius="5" Margin="5">
<StackPanel Orientation="Horizontal" Width="auto" Background="Red">
<Image Width="24" Height="24" Source="/My.Images;component/Warning.png" />
<TextBlock x:Name="lblStoryboard"
TextAlignment="Center"
Padding="5"
Width="Auto"
Background="Red"
Foreground="Black"
FontSize="12.5"
FontWeight="Bold"
Style="{StaticResource BlinkingTextBlock}"
Text="Hi there!"
TextWrapping="WrapWithOverflow"
Visibility="{Binding Path=BlinkOn, Converter={StaticResource BoolToVis}}">
</TextBlock>
</StackPanel>
</Border>