当前位置: 首页 > 编程语言 > C#

从代码共享更新LinearDoubleKeyFrameKeyTime值

时间:2023-04-10 13:37:59 C#

从代码更新LinearDoubleKeyFrameKeyTime值我有一些这样的xaml:我想做的是从C#中的UserControl代码更新LinearDoubleKeyFrame元素的KeyTime值。我想也许我可以通过x:Name引用元素来做到这一点,但我没有取得太大的成功。我还想也许我可以将值绑定到后面代码中的字段,但这也不起作用。有没有人有任何线索可以将我推向正确的方向。谢谢Phil您如何尝试在代码中引用LinearDoubleKeyFrame对象?我觉得你需要做几件事:以上是C#学习教程:从代码中更新LinearDoubleKeyFrameKeyTime值分享的所有内容,如果对大家有用需要进一步了解C#学习教程,希望大家多多关注——varstoryboard=(Storyboard)FindResource("onLoadeducLogo");varanimation=(DoubleAnimationUsingKeyFrames)storyboard.Children[0];varkeyframe1=animation.KeyFrames[0];keyframe1.KeyTime=KeyTime.FromTimeSpan(newTimeSpan(0,0,0,1));//1秒图像creatureImage=newImage();故事板fadeInFadeOut=newStoryboard();DoubleAnimationUsingKeyFramesdbAnimation=newDoubleAnimationUsingKeyFrames();dbAnimation.Duration=TimeSpan.FromSeconds(2);lDKF1.Value=1;lDKF1.KeyTime=TimeSpan.FromSeconds(0);dbAnimation.KeyFrames.Add(lDKF1);//LinearDoubleKeyFramelDKF2=newLinearDoubleKeyFrame();lDKF2.Value=0.6;lDKF2.KeyTime=TimeSpan.FromSeconds(0.5);dbAnimation.KeyFrames.Add(lDKF2);//LinearDoubleKeyFramelDKF3=newLinearDoubleKeyFrame();lDKF3.Value=1;lDKF3.KeyTime=TimeSpan.FromSeconds(0.5);dbAnimation.KeyFrames.Add(lDKF3);//LinearDoubleKeyFramelDKF4=newLinearDoubleKeyFrame();lDKF4.Value=0;lDKF4.KeyTime=TimeSpan.FromSeconds(1);dbAnimation.KeyFrames.Add(lDKF4);Storyboard.SetTarget(dbAnimation,creatureImage);Storyboard.SetTargetProperty(dbAnimation,newPropertyPath(Image.OpacityProperty));fadeInFadeOut.Children.Add(dbAnimation);整理自网络,不代表立场。如涉及侵权,请点击右侧联系管理员删除。如有转载请注明出处: