闪烁的文本块 [英] Blinking TextBlock

查看:34
本文介绍了闪烁的文本块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使 Wpf TextBlock 闪烁.我想当我点击一个按钮时,文本块会闪烁.我怎样才能做到这一点.

Hi iam trying to make an Wpf TextBlock to blink. I want like when im clicking on an button then the textblock blinks. How can i achive this.

我尝试了以下方法.

<TextBlock Name="txtBlockScannerText" Margin="10,0,0,0" Style="{StaticResource TextBlockNormal}" Text="Skanna Inleverans listan">
    <TextBlock.Triggers>
        <EventTrigger RoutedEvent="TextBlock.MouseEnter">
            <EventTrigger.Actions>
                <BeginStoryboard>
                    <Storyboard BeginTime="00:00:00" RepeatBehavior="Forever" Storyboard.TargetName="txtBlockScannerText" Storyboard.TargetProperty="(Foreground).(SolidColorBrush.Color)">
                        <ColorAnimation From="Black" To="Red" Duration="0:0:1"/>
                    </Storyboard>
                </BeginStoryboard>
            </EventTrigger.Actions>
        </EventTrigger>
    </TextBlock.Triggers>
</TextBlock>

但是使用此代码时,它只会在我的鼠标输入时闪烁.如何在按钮单击事件中触发闪烁.或者我如何调用事件闪烁.感谢帮助

But with this code it only blinks when my mouse enter it. How can i trigger the blink in an button click event. Or how do i call the event to blink. Thanks for help

推荐答案

TextBlock 上没有单击事件.如果您使用带有文本块的按钮作为内容,您可以将动画连接到按钮的点击事件.您可能需要为按钮设置样式以移除 3D 外观或您可以选择其他按钮作为默认样式.

There's no click event on a TextBlock. If you use a button with the textblock as content you can hook up your animation to the button's click event. You may need to style the button to remove 3D look or what else you may choose as default style for your buttons.

这篇关于闪烁的文本块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆