请问这段动画用C#怎么处理?
功能是在0.5秒之内将字体从粗体变为正常.我用了Blend做出来了,但是用C#不知道应该怎么做。
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(TextBlock.FontWeight)" Storyboard.TargetName="_3TextBlock">
<DiscreteObjectKeyFrame KeyTime="0">
<DiscreteObjectKeyFrame.Value>
<FontWeight>Bold</FontWeight>
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
<DiscreteObjectKeyFrame KeyTime="0:0:0.5">
<DiscreteObjectKeyFrame.Value>
<FontWeight>Normal</FontWeight>
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
[解决办法]
ObjectAnimationUsingKeyFrames animation=new ObjectAnimationUsingKeyFrames();
DiscreteObjectKeyFrame k1=new DiscreteObjectKeyFrame();
DiscreteObjectKeyFrame k2=new DiscreteObjectKeyFrame();
k1.KeyTime=KeyTime.FromPercent(0);
k1.Value=FontWeights.Bold;
k2.KeyTime = KeyTime.FromTimeSpan(TimeSpan.Parse("0:0:0.5"));
k2.Value=FontWeights.Normal;
animation.KeyFrames.Add(k1);
animation.KeyFrames.Add(k2);
this._3TextBlock.BeginAnimation(TextBlock.FontWeightProperty,animation);
dispatcherTimer.Start();
void dispatcherTimer_Tick(object sender, EventArgs e)
{
DispatcherTimer dispatcherTimer = sender as DispatcherTimer;
textBlock.FontWeight = FontWeights.Normal;
dispatcherTimer.Stop();
}