私はアニメーションに比較的慣れていないので、少し方向性を探しています。List<Label>
15 個のラベルがロードされているとします。DoubleAnimation
不透明度を m 0 から 1 に 500 ミリ秒でアニメーション化します。ループしたいのですが、これらのラベルは 1000 ミリ秒ごとにアニメーションを開始します。したがって、label1 は 0ms で始まり、label2 は 1000ms で始まります。
Storyboard.Duration
aを 1000ms*15 に設定し、ラベルを SB に追加して開始できることはわかっていますが、アニメーションは SB に追加されるのと同じ速さで再生されます。特定の時間間隔でアニメーションを SB に追加する方法はありますか?
編集:
私はList<Label>
もう使用していませんここに私が書いたコードがあります
class MessageWriter
{
Storyboard _sb = new Storyboard();
public MessageWriter()
{
}
public void ProcessMessage(string _Message, WrapPanel _Panel)
{
string[] _Words = _Message.Split(new char[1]{Convert.ToChar(" ")});
int _Counter = 1;
_sb = new Storyboard();
foreach (string _Word in _Words)
{
_Panel.Children.Add(ProcessWord(_Word));
if (_Counter < _Words.Length)
{
_Panel.Children.Add(ProcessWord(" "));
}
_Counter++;
}
_sb.Begin();
}
private StackPanel ProcessWord(string _Word)
{
Debug.Print(_Word);
StackPanel _Panel = new StackPanel();
_Panel.Orientation = Orientation.Horizontal;
_Panel.Margin = new System.Windows.Thickness(0, 0, 0, 0);
foreach (char _c in _Word.ToList())
{
Label _Label = new Label();
_Label.Opacity = 0;
_Label.Margin = new System.Windows.Thickness(0, 0, 0, 0);
_Label.Padding = new System.Windows.Thickness(0, 0, 0, 0);
_Label.Content = _c.ToString();
_Panel.Children.Add(_Label);
AnimateLabel(_Label);
}
return _Panel;
}
private void AnimateLabel(Label _Label)
{
DoubleAnimation _da = new DoubleAnimation();
_da.From = 0;
_da.To = 1;
int _MillSec = 500;
_da.Duration = new System.Windows.Duration(new TimeSpan(0, 0, 0, 0, _MillSec));
Storyboard.SetTargetProperty(_da, new PropertyPath(FrameworkElement.OpacityProperty));
Storyboard.SetTarget(_da, _Label);
_sb.Children.Add(_da);
}
}