Hi Everyone, I have tried converting this piece of code into csharp but have met with some issues. Anyone with ideas as to how this may be done. My current application presently is a tabbed control with an ellipse and a button. Clicking on the button is supposed to animate the ellipse. Thanks
Updates:
Converting
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)"
to codes is really the issue. I am currently working on moving most of my xaml codes to c sharp so that these storyboards could be used on any element in the application. The whole idea is to take advantage of the api on http://animatedotnet.codeplex.com/.
As regards converting the xaml code to csharp, here is how far I have gone
DoubleAnimationUsingKeyFrames DK = new DoubleAnimationUsingKeyFrames();
TranslateTransform TT = new TranslateTransform();
EasingDoubleKeyFrame ED = new EasingDoubleKeyFrame();
ED.KeyTime = TimeSpan.FromSeconds((0));
ED.Value = 19.50;
ED.KeyTime = TimeSpan.FromSeconds((0.1));
ED.Value = -108;
ED.KeyTime = TimeSpan.FromSeconds((0.3));
ED.Value = -133.5;
ED.KeyTime = TimeSpan.FromSeconds((0.6));
ED.Value = -28.50;
ED.KeyTime = TimeSpan.FromSeconds((0.8));
ED.Value = 18;
ED.KeyTime = TimeSpan.FromSeconds((1.0));
ED.Value = 18;
DK.KeyFrames.Add(ED);
//RenderTransform RT = new RenderTransform();
TransformGroup TG = new TransformGroup();
this.RegisterName(
"TG", TG);
TG.Children.Add(TT);
//TG.Children.Add(DK);
Bal.RenderTransform = TG;
Storyboard.SetTargetName(DK, "TG");
Storyboard.SetTargetProperty(
DK, new PropertyPath(TranslateTransform.XProperty));
//Bal.tras
DoubleAnimationUsingKeyFrames DK2 = new DoubleAnimationUsingKeyFrames();
TranslateTransform TT2 = new TranslateTransform();
EasingDoubleKeyFrame ED2 = new EasingDoubleKeyFrame();
ED.KeyTime = TimeSpan.FromSeconds((0));
ED.Value = -6;
ED.KeyTime = TimeSpan.FromSeconds((0.1));
ED.Value = -46.5;
ED.KeyTime = TimeSpan.FromSeconds((0.3));
ED.Value = -141;
ED.KeyTime = TimeSpan.FromSeconds((0.6));
ED.Value = -154.5;
ED.KeyTime = TimeSpan.FromSeconds((0.8));
ED.Value = -157.5;
ED.KeyTime = TimeSpan.FromSeconds((1.0));
ED.Value = -157.5;
DK.KeyFrames.Add(ED2);
//RenderTransform RT = new RenderTransform();
TransformGroup TG2 = new TransformGroup();
this.RegisterName(
"TG2", TG2);
TG.Children.Add(TT2);
//TG.Children.Add(DK);
Bal.RenderTransform = TG2;
Storyboard.SetTargetName(DK2, "TG2");
Storyboard.SetTargetProperty(
DK2, new PropertyPath(TranslateTransform.YProperty));
testt.Children.Add(DK);
testt.Children.Add(DK2);
<Storyboard x:Key="iter">
<DoubleAnimationUsingPath Duration="0:0:2" Source="X" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)" Storyboard.TargetName="ellipse">
<DoubleAnimationUsingPath.PathGeometry>
<PathGeometry Figures="M41,105 C41,185.90972 -23.247138,251.5 -102.5,251.5 C-181.75286,251.5 -246,185.90972 -246,105 C-246,24.090284 -181.75286,-41.5 -102.5,-41.5 C-23.247138,-41.5 41,24.090284 41,105 z"/>
</DoubleAnimationUsingPath.PathGeometry>
</DoubleAnimationUsingPath>
<DoubleAnimationUsingPath Duration="0:0:2" Source="Y" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)" Storyboard.TargetName="ellipse">
<DoubleAnimationUsingPath.PathGeometry>
<PathGeometry Figures="M41,105 C41,185.90972 -23.247138,251.5 -102.5,251.5 C-181.75286,251.5 -246,185.90972 -246,105 C-246,24.090284 -181.75286,-41.5 -102.5,-41.5 C-23.247138,-41.5 41,24.090284 41,105 z"/>
</DoubleAnimationUsingPath.PathGeometry>
</DoubleAnimationUsingPath>
</Storyboard>