.net 关键帧对象上的KeyTime属性必须设置为非负TimeSpan值?
全部, 有人能告诉我为什么这个键时间告诉我它在运行时是负值吗?我删除了一些构建图像路径的逻辑.net 关键帧对象上的KeyTime属性必须设置为非负TimeSpan值?,.net,wpf,silverlight,animation,storyboard,.net,Wpf,Silverlight,Animation,Storyboard,全部, 有人能告诉我为什么这个键时间告诉我它在运行时是负值吗?我删除了一些构建图像路径的逻辑 public Storyboard CreateAnimationStoryBoard(DependencyObject dependencyObjectTarget,Image targetImage) { try { Storyboard sb = new Storyboard(); Storyboard.SetT
public Storyboard CreateAnimationStoryBoard(DependencyObject dependencyObjectTarget,Image targetImage)
{
try
{
Storyboard sb = new Storyboard();
Storyboard.SetTarget(sb, dependencyObjectTarget);
Storyboard.SetTargetName(sb, targetImage.Name);
Storyboard.SetTargetProperty(sb, new PropertyPath(Image.SourceProperty));
ObjectAnimationUsingKeyFrames oaukf = new ObjectAnimationUsingKeyFrames();
oaukf.Duration = TimeSpan.FromSeconds(animationLength);
oaukf.BeginTime = new TimeSpan(0, 0, 0);
for (int i = startFrame; i <= endFrame; i++)
{
*build an animation string path here (hidden)*
Uri u;
Uri.TryCreate(animationString.ToString(), UriKind.RelativeOrAbsolute, out u);
BitmapImage bi = new BitmapImage(u);
DiscreteObjectKeyFrame dokf = new DiscreteObjectKeyFrame();
dokf.KeyTime = KeyTime.Uniform;
dokf.Value = bi;
oaukf.KeyFrames.Add(dokf);
}
sb.Children.Add(oaukf);
return sb;
}
公共故事板CreateAnimationStoryBoard(DependencyObject dependencyObjectTarget,Image targetImage)
{
尝试
{
情节提要sb=新情节提要();
Storyboard.SetTarget(sb,dependencyObjectTarget);
故事板.SetTargetName(sb,targetImage.Name);
Storyboard.SetTargetProperty(sb,新属性路径(Image.SourceProperty));
ObjectAnimationUsingKeyFrames oaukf=新建ObjectAnimationUsingKeyFrames();
oaukf.Duration=TimeSpan.FromSeconds(animationLength);
oaukf.BeginTime=新的时间跨度(0,0,0);
对于(int i=startFrame;i来说,您对Keytime变量的使用有点不恰当:
在设置关键帧时,如“在可见性上”,请使用以下命令:
DiscreteObjectKeyFrame kf = new DiscreteObjectKeyFrame();
kf.KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(1000));
kf.Value = Visibility.Visible;