正如新闻广播中的文字字幕 [英] Text Marquee as in the newscasts

查看:75
本文介绍了正如新闻广播中的文字字幕的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个代码,用于移动文本Marquee,就像你在新闻广播中看到的那样。它在Windows窗体中工作,但不在WPF中工作。

I have this code, is for move a text Marquee as you can see in the newscasts. It working in Windows Form, but not in WPF.

this.Refresh();
myLabel2.Left += 5;
if (myLabel2.Left >= this.Width)
{
    myLabel2.Left = myLabel2.Width * -1;
}



我想创建Text Marquee以获取新消息。在TextBox中,您可以添加新消息,稍后将更新TextBlock。有人有想法吗?



我也很感激!我是.net的新手,我有一个很大的项目:$


I want to create that Text Marquee for fresh news. In a TextBox you can add a fresh news, and later in a TextBlock is updated. Somebody have a idea?

I will appreciate too! I'm new with .net and I have a big proyect :$

推荐答案


尝试将动画应用到文本框中。

类似于下面的代码。

Try applying animation to the textbox.
Something similar to the below code.
void Window1_Loaded(object sender, RoutedEventArgs e)

    {

        DoubleAnimation doubleAnimation = new DoubleAnimation();

        doubleAnimation.From = -tbmarquee.ActualWidth;

        doubleAnimation.To = canMain.ActualWidth;

        doubleAnimation.RepeatBehavior = RepeatBehavior.Forever;

        doubleAnimation.Duration = new Duration(TimeSpan.Parse("0:0:10"));

        tbmarquee.BeginAnimation(Canvas.LeftProperty, doubleAnimation);

    }





参考:

http://stackoverflow.com/questions/20145212/ [ ^ ]



在WPF中制作简单的选框文本控制,滴灌动画和滚动动画 [ ^ ]


这篇关于正如新闻广播中的文字字幕的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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