功能是在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);
------解决方案--------------------------------------------------------
非常不错!
------解决方案--------------------------------------------------------
每一个节点都是对象
可以看看msdn 这些对象 用c# 是如何使用的
------解决方案--------------------------------------------------------
DispatcherTimer dispatcherTimer = new DispatcherTimer();
dispatcherTimer.Tick += new EventHandler(dispatcherTimer_Tick);
dispatcherTimer.Interval = TimeSpan.FromMilliseconds(500);