【发布时间】:2019-05-19 03:10:33
【问题描述】:
我有一个包含图像和文本块的堆栈面板。
TextBlock 绑定到一种样式,使其闪烁,背景颜色从红色变为黑色,反之亦然。
我想将TextBlock背景色绑定到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>
【问题讨论】:
标签: c# wpf xaml binding .net-3.5