在 Microsoft 的 Expression Blend 3 SketchFlow 应用程序中。
您将如何制作文本输入的动画,最好是按角色风格分阶段进行。就像用户正在输入一样。
关联的闪烁光标会使它变得完美,但这远远超出了“拥有就好”的境界。
关键帧动画系统,不允许你操纵
Common Property > Text
字段,因此它不会作为动画关键帧中记录的更改持续存在。
我正在寻找编辑器步骤(使用某种其他控件)甚至 XAML 代码...
<VisualState>
<StoryBoard>
<DoubleAnimationUsingKeyFrame ... >
最佳答案
在用 solution involving a wipe animation 写博客讨论此事之后文本 block 上的矩形,响应博客文章,具有更高级的解决方案 using a custom behavior附加到文本 block 已创建。
创建“TypeOnAction”行为并添加到 TextBlock,将提供逐个字符显示所需的效果,并具有可自定义的出现率。获取完整代码示例 here .
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));
}
关于silverlight - 如何在 SketchFlow 中对 "typing"文本进行动画处理?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1322232/