首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 媒体动画 > CAD教程 >

请教这段动画用C#怎么办

2013-01-04 
请问这段动画用C#怎么处理? 功能是在0.5秒之内将字体从粗体变为正常.我用了Blend做出来了,但是用C#不知道

请问这段动画用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);

[解决办法]
引用:
C# code

ObjectAnimationUsingKeyFrames animation=new ObjectAnimationUsingKeyFrames();
    DiscreteObjectKeyFrame k1=new DiscreteObjectKeyFrame();
    DiscreteObjectKeyFrame k2=new DiscreteObjectKeyF……
非常不错!
[解决办法]
每一个节点都是对象 
可以看看msdn 这些对象 用c# 是如何使用的  
[解决办法]
            DispatcherTimer dispatcherTimer = new DispatcherTimer();
            dispatcherTimer.Tick += new EventHandler(dispatcherTimer_Tick);
            dispatcherTimer.Interval = TimeSpan.FromMilliseconds(500);


            dispatcherTimer.Start();


        void dispatcherTimer_Tick(object sender, EventArgs e)
        {
            DispatcherTimer dispatcherTimer = sender as DispatcherTimer;
            textBlock.FontWeight = FontWeights.Normal;
            dispatcherTimer.Stop();
        }

热点排行