0
private void Window_Loaded(object sender, RoutedEventArgs e)
{
StringAnimationUsingKeyFrames sAnimation = new StringAnimationUsingKeyFrames();
int full = 100;
double key = 4000/full;
for (var i = 100; i >= 0; i--)
{
TimeSpan keyTime = TimeSpan.FromMilliseconds((100 - i) * key);
DiscreteStringKeyFrame frame = new DiscreteStringKeyFrame(i.ToString(), KeyTime.FromTimeSpan(keyTime));
sAnimation.KeyFrames.Add(frame);
}
Storyboard.SetTarget(sAnimation, textCount);
Storyboard.SetTargetProperty(sAnimation, new PropertyPath(TextBlock.TextProperty));
Storyboard sb = new Storyboard();
sb.Children.Add(sAnimation);
sb.Completed += sb_Completed;
sb.Begin(this);
}
private void sb_Completed(object sender, EventArgs e)
{
textCount.Text = "50";
}
이것은 내 코드입니다.'StringAnimationUsingKeyFrames'이후에 텍스트 블록의 값을 변경할 수 없습니다.
이 코드는 0
로 변경 된 본체 값 100 그리고 카운트 다운하는 것은 완료된 후 TextBlock의 값을 변경하고 싶습니다.
하지만 카운트 다운 (애니메이션 처리)이 완료 되더라도 변경되지 않습니다. (스토리 보드 완료시 텍스트 블록 값 변경 시도)
어떻게하면됩니까?
그러나 FillBehavior.Stop을 설정하면 텍스트가 애니메이트 한 후에 사라집니다. –
어쨌든 애니메이션 이후에 텍스트를 변경하려고한다고 생각하는 것은 유감입니다. 애니메이션 후에도 텍스트를 유지하려면 한 가지 더 할 수 있습니다. 스토리 보드의 완성 된 이벤트에 다음 행을 삽입 할 수 있습니다. - textCount.BeginAnimation (TextBlock.TextProperty, null); – Precog