Silverlight 如何制作“动画”;打字;SketchFlow中的文本?

Silverlight 如何制作“动画”;打字;SketchFlow中的文本?,silverlight,xaml,animation,keyframe,Silverlight,Xaml,Animation,Keyframe,在Microsoft的Expression Blend 3 SketchFlow应用程序中 您将如何设置文本的键入动画,理想情况下是以逐角色分段的方式。就像用户正在键入它一样 一个相关的闪烁光标将使它变得完美,但这远远超出了“拥有美好”的范畴 关键帧动画系统不允许您操纵关键帧 公共属性>文本 因此,它不会作为动画关键帧中记录的更改而保留 我正在寻找编辑器步骤(使用某种其他控件)甚至XAML代码 <VisualState> <StoryBoard>

在Microsoft的Expression Blend 3 SketchFlow应用程序中

您将如何设置文本的键入动画,理想情况下是以逐角色分段的方式。就像用户正在键入它一样

一个相关的闪烁光标将使它变得完美,但这远远超出了“拥有美好”的范畴

关键帧动画系统不允许您操纵关键帧

公共属性>文本

因此,它不会作为动画关键帧中记录的更改而保留

我正在寻找编辑器步骤(使用某种其他控件)甚至XAML代码

<VisualState>
    <StoryBoard>
        <DoubleAnimationUsingKeyFrame ... >

在写了一篇关于这个问题的博客后,在一个文本块上放置了一个矩形,然后创建了一篇带有更高级的解决方案“附加到文本块”的响应博客文章

创建“TypeOnAction”行为并添加到文本块,将提供所需的逐字符显示效果,并具有可自定义的显示率。获取完整的代码示例

公共类TypeOnAction:TriggerAction
{
调度定时器;
int len=1;
公共类型操作()
{
计时器=新调度程序();
}
受保护的覆盖无效调用(对象o)
{
if(AssociatedObject==null)
返回;
AssociatedObject.Text=“”;
timer.Interval=TimeSpan.FromSeconds(间隔秒);
timer.Tick+=新事件处理程序(timer\u Tick);
len=1;
timer.Start();
}
无效计时器勾号(对象发送方,事件参数e)
{

如果(len>0&&len)我2009年8月的博客文章对我的方法不够详细,所以我最近更新了它,并在GitHub上添加了一些示例源代码-(用于擦除动作动画方法)。
public class TypeOnAction : TriggerAction<TextBlock>
{
    DispatcherTimer timer;
    int len = 1;

    public TypeOnAction()
    {
        timer = new DispatcherTimer();
    }

    protected override void Invoke(object o)
    {
        if (AssociatedObject == null)
            return;

        AssociatedObject.Text = "";
        timer.Interval = TimeSpan.FromSeconds(IntervalInSeconds);
        timer.Tick += new EventHandler(timer_Tick);
        len = 1;
        timer.Start();
    }

    void timer_Tick(object sender, EventArgs e)
    {
        if (len > 0 && len <= TypeOnText.Length)
        {
            AssociatedObject.Text = TypeOnText.Substring(0, len);
            len++;
            timer.Start();
        }
        else
            timer.Stop();
    }

    public string TypeOnText
    {
        get { return (string)GetValue(TypeOnTextProperty); }
        set { SetValue(TypeOnTextProperty, value); }
    }

    public static readonly DependencyProperty TypeOnTextProperty =
        DependencyProperty.Register("TypeOnText", typeof(string), typeof(TypeOnAction), new PropertyMetadata(""));

    public double IntervalInSeconds
    {
        get { return (double)GetValue(IntervalInSecondsProperty); }
        set { SetValue(IntervalInSecondsProperty, value); }
    }

    public static readonly DependencyProperty IntervalInSecondsProperty =
        DependencyProperty.Register("IntervalInSeconds", typeof(double), typeof(TypeOnAction), new PropertyMetadata(0.35));

}