WPF为提示信息文本增加闪烁效果


程序通常需要显示某些提醒用户警示的信息,如:收件箱(40)其中数量闪烁就会起到警示效果。可以适用如下Storyboard实现:

<ItemsControl.ItemTemplate>
<DataTemplate>
    <Button Command="{x:Static local:QueryRecordItem.OpenCommand}" FocusVisualStyle="{x:Null}" Focusable="False"
            ContextMenu="{StaticResource ShellContextMenu}" ToolTip="{Binding ToolTip}">
        <StackPanel Orientation="Horizontal">
            <TextBlock Text="{Binding Description}"/>
            <TextBlock Text="{Binding TipText}" Foreground="Red" Visibility="{Binding Converter={x:Static jsm:Converters.BooleanToVisibility}, Path=HasItem, ConverterParameter=true}"/>
            <Border Background="Red" CornerRadius="5" Visibility="{Binding Converter={x:Static jsm:Converters.BooleanToVisibility}, Path=HasItem}">
                <Border.Triggers>
                    <EventTrigger RoutedEvent="Loaded">
                        <BeginStoryboard>
                            <Storyboard BeginTime="0:0:0" AutoReverse="True" RepeatBehavior="Forever">
                                <ColorAnimation From="Red" To="Navy" RepeatBehavior="Forever" Storyboard.TargetProperty="Background.Color">
                                </ColorAnimation>
                            </Storyboard>
                        </BeginStoryboard>
                    </EventTrigger>
                </Border.Triggers>
                <TextBlock Text="{Binding TipText}" Foreground="White"/>
            </Border>
        </StackPanel>
    </Button>
</DataTemplate>
</ItemsControl.ItemTemplate>

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM