使用WPF的平滑文本动画(字幕) [英] Smooth text animation (Marquee) using WPF

查看:308
本文介绍了使用WPF的平滑文本动画(字幕)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试使用平滑的文本动画构建字幕控件。当前的工作包括:

Trying to build a marquee control with smooth text animation. Current efforts include:


  • 使用翻译变换

  • 在Canvas依赖项属性上使用动画(左,右)

  • 在自定义依赖项属性(点)上使用动画,并使用图形效果(格式文本)

  • 使用CompositionTarget.Rendering

  • Using translate transform
  • Using animation on Canvas dependency properties (Left, Right)
  • Using animation on custom dependency property (Point) and using drawing visuals (formattedtext)
  • Using CompositionTarget.Rendering

但是动画仍然很不稳定并且占用大量资源(2-10%的CPU)。

But the animation is still choppy and resource intensive (2-10% CPU).

测试代码我认为应该在默认的wpf窗口中使用该动画:

Test code used in default wpf window which I assume should produce a smooth animation:

   <TextBlock x:Name="_box" FontSize="64" CacheMode="BitmapCache" Text="lorem ipsum">
        <TextBlock.RenderTransform>
            <TranslateTransform x:Name="AnimatedTranslateTransform" X="0" Y="0" />
        </TextBlock.RenderTransform>
        <TextBlock.Triggers>
            <EventTrigger RoutedEvent="TextBlock.Loaded">
              <BeginStoryboard>
                <Storyboard>
                  <DoubleAnimation
                    Storyboard.TargetName="AnimatedTranslateTransform" 
                    Storyboard.TargetProperty="X"
                    From="-300" To="300" Duration="0:0:5" 
                    AutoReverse="True" RepeatBehavior="Forever" />
                </Storyboard>
              </BeginStoryboard>
            </EventTrigger>
          </TextBlock.Triggers>
    </TextBlock>

清单:


  • 确认没有进行任何软件渲染(使用ms性能工具并检查RenderCapability.Tier)

  • 在任何可想象的对象上调用冻结

  • 禁用任何可渲染对象位图效果和透明度

  • 检查了所有选框控件(相同的问题)

  • Confirmed no software rendering is taking place (ms performance tool and checking RenderCapability.Tier)
  • Calling freeze on any imaginable object
  • Disabled any bitmap effect and transparency
  • Checked all marquee controls out there (same issues)


  • CPU:智能2核(T6600)@ 2.2Ghz

  • RAM:4GB

  • GPU:NVidia GeForce 9600M GS(最新驱动程序)

  • 操作系统:Windows 7(64位)

  • CPU: Intell core 2 duo (T6600) @2.2Ghz
  • RAM: 4GB
  • GPU: NVidia GeForce 9600M GS (latest drivers)
  • OS: Windows 7 (64bit)

有任何想法(或更好的代码示例)吗?

Any ideas (or better yet code example)?

从响应中看,这似乎不是wpf问题(其他选框)控件可以很好地为其他人(而不是我)工作),但我在进行此测试的每台计算机上都遇到了同样的问题。

From the responses it seems this is not a wpf issue (other marquee controls work fine for others but not for me), nut I'm getting the same issues on every machine I tested this on.

推荐答案

希望这对您有所帮助- http://jobijoy.blogspot.com/2008/08/silverlight-marquee-control.html

Hope this may help you - http://jobijoy.blogspot.com/2008/08/silverlight-marquee-control.html

您也可以在此处找到WPF版本

And the WPF version also can be found here

这篇关于使用WPF的平滑文本动画(字幕)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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