Smooth text animation (Marquee) using WPF

前端 未结 3 1610
春和景丽
春和景丽 2020-12-01 15:29

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

  • Using translate transform
  • Using animation on Canvas dependency
3条回答
  •  悲哀的现实
    2020-12-01 15:47

    Your animation will be handled entirely at the MilCore layer if:

    1. Your TranslateTransform is a RenderTransform (not a LayoutTransform), and
    2. You use a simple animation such as a DoubleAnimation, and
    3. Your object has no clipping or opacity calculations

    Try using a DoubleAnimation-animated TranslateTransform for a RenderTransform on a TextBlock that is a direct child of a Window with default settings.

    • If this is still slow, there is something slow about your Direct3D system because managed code is not involved at all and MilCore's calls are very simple, but

    • If it works smoothly and efficiently, incrementally change it to your poorly-performing code to see what change causes the slowdown.

    Given your response to Jobi Joy's answer I would suspect the problem is somewhere in your hardware or Direct3D setup, but the only way to find out is to test it.

提交回复
热议问题