So i'm trying to create animation on the fly in C#, but i'm running into a funny bug when i try to set the Children property on the Storyboard object. The API claims that the Children property is of type TimelineCollection. However, the intellicense begs to differ and exposes it simply as one Timeline object instead. That is weird. The second weird thing is that i can not seem to set that property even if i wanted to. It simply runs into that code, and disappears into code oblivion. An exception of some sort is thrown, but nothing that i can recognize. I'd also like to be able to set the Storyboard.TargetName property on the fly; again, that seems to bomb out. Could someone help me here. I have pasted the code below. The conflict spots are in bold...Thank you,
Haider
Storyboard xSB = new Storyboard();
TimelineCollection timeLines = new TimelineCollection();
KeyFrameCollection keyFramez;
DoubleAnimationUsingKeyFrames anim;
//1st Animation
anim = new DoubleAnimationUsingKeyFrames();
keyFramez = new KeyFrameCollection();
anim.SetValue<string>(Storyboard.TargetPropertyProperty, "(FrameworkElement.Width)");
SplineDoubleKeyFrame xSDKeyFrame = new SplineDoubleKeyFrame();
xSDKeyFrame.Value = 130;
xSDKeyFrame.KeyTime = TimeSpan.FromSeconds(0.1);
keyFramez.Add(xSDKeyFrame);
anim.KeyFrames = keyFramez;
timeLines.Add(anim);
xSB.Children = anim;
try
{
xSB.SetValue<Timeline>(Storyboard.ChildrenProperty, timeLines[0]);
xSB.SetValue<string>(Storyboard.TargetNameProperty, ((Image)sender).Name);
}
catch (Exception ex)
{
throw ex;
}
xSB.Begin();