gpt4 book ai didi

wpf - 有 WPF 打字机效果吗?

转载 作者:行者123 更新时间:2023-12-05 00:50:45 27 4
gpt4 key购买 nike

WPF 中有没有相当于 Flash 的打字机效果?

最佳答案

好的,我成功了!

private void TypewriteTextblock(string textToAnimate, TextBlock txt, TimeSpan timeSpan)
{
Storyboard story = new Storyboard();
story.FillBehavior = FillBehavior.HoldEnd;
story.RepeatBehavior = RepeatBehavior.Forever;

DiscreteStringKeyFrame discreteStringKeyFrame;
StringAnimationUsingKeyFrames stringAnimationUsingKeyFrames = new StringAnimationUsingKeyFrames();
stringAnimationUsingKeyFrames.Duration = new Duration(timeSpan);

string tmp = string.Empty;
foreach(char c in textToAnimate)
{
discreteStringKeyFrame = new DiscreteStringKeyFrame();
discreteStringKeyFrame.KeyTime = KeyTime.Paced;
tmp += c;
discreteStringKeyFrame.Value = tmp;
stringAnimationUsingKeyFrames.KeyFrames.Add(discreteStringKeyFrame);
}
Storyboard.SetTargetName(stringAnimationUsingKeyFrames, txt.Name);
Storyboard.SetTargetProperty(stringAnimationUsingKeyFrames, new PropertyPath(TextBlock.TextProperty));
story.Children.Add(stringAnimationUsingKeyFrames);

story.Begin(txt);
}

但是有没有办法让角色淡入?

关于wpf - 有 WPF 打字机效果吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3430659/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com