2009-08-24 12 views
2

MicrosoftのExpression Blend 3 SketchFlowアプリケーション。SketchFlowで「タイピング」テキストをアニメーション化する方法は?

の入力は、理想的にはキャラクタごとに段階的に行われます。のアニメーション化についてはどうでしょうか。ユーザーが入力しているかのように。

関連する点滅カーソルがあれば完璧になりますが、それは「持っていればいい」という領域にあります。

キーフレームアニメーションシステムは、あなたがそうので、それがアニメーションのキーフレームで記録された変化として保持されません

共通プロパティ]> [テキスト

フィールドを操作することはできません。私は、さらにXAMLコード(いくつかの他のコントロールの種類を使用して)、エディタの手順のいずれかを探しています

...

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

答えて

3

テキストブロックの上に長方形の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)); 

} 
+0

私の2009年8月のブログ記事は、私のアプローチに十分な詳細ではなかったので、私は最近、それを更新し、GitHubの上でいくつかのサンプルソースコードを追加しましたアクションアニメーションアプローチ)。 –

関連する問題