テキストブロックの上に長方形のsolution involving a wipe animationでこれについてのブログの後、テキストブロックに添付されたusing a custom behaviorのより高度な解決策を備えた応答ブログ投稿が作成されました。
'TypeOnAction'ビヘイビアを作成し、TextBlockに追加することで、カスタマイズ可能な出現率のキャラクタディスプレイによる文字の効果が得られます。完全なコードサンプルhereを入手してください。ワイプのために(http://github.com/NickJosevski/SketchFlowSamples -
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));
}
私の2009年8月のブログ記事は、私のアプローチに十分な詳細ではなかったので、私は最近、それを更新し、GitHubの上でいくつかのサンプルソースコードを追加しましたアクションアニメーションアプローチ)。 –