# Programatically set Silverlight rotational transform

**URL:** https://forum.kirupa.com/t/programatically-set-silverlight-rotational-transform/270851
**Category:** programming
**Created:** [September 15, 2008, 2:43pm UTC](https://forum.kirupa.com/t/programatically-set-silverlight-rotational-transform/270851 "2008-09-15T14:43:48Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Nilserik](https://avatars.discourse-cdn.com/v4/letter/n/9dc877/32.png) [@Nilserik](https://forum.kirupa.com/u/Nilserik)
#### Post date: [September 15, 2008, 2:43pm UTC](https://forum.kirupa.com/t/programatically-set-silverlight-rotational-transform/270851/1 "2008-09-15T14:43:48Z")

</div>

Hi,  
i have tried to wrap my head around Silverlight and got a bit stuck on how to programatically add a rotational transform to a storyboard, i’ve tried a lot of different options and also spent some time looking for documentation but i’ve come up short.  
This is what I have tried most recently:

[SIZE=2][COLOR=#2b91af]DoubleAnimation[/COLOR][/SIZE][SIZE=2] myDoubleAnimation = [/SIZE][SIZE=2][COLOR=#0000ff]new[/COLOR][/SIZE][SIZE=2][COLOR=#2b91af]DoubleAnimation[/COLOR][/SIZE]SIZE=2;[/SIZE]  
[SIZE=2]myDoubleAnimation.Duration = duration;[/SIZE]

[SIZE=2][COLOR=#2b91af]Storyboard[/COLOR][/SIZE][SIZE=2] sb = [/SIZE][SIZE=2][COLOR=#0000ff]new[/COLOR][/SIZE][SIZE=2][COLOR=#2b91af]Storyboard[/COLOR][/SIZE]SIZE=2;[/SIZE]  
[SIZE=2]sb.Duration = duration;[/SIZE]

[SIZE=2]sb.Children.Add(myDoubleAnimation);[/SIZE]

[SIZE=2][COLOR=#2b91af]Rectangle[/COLOR][/SIZE][SIZE=2] rectangle = [/SIZE][SIZE=2][COLOR=#0000ff]new[/COLOR][/SIZE][SIZE=2][COLOR=#2b91af]Rectangle[/COLOR][/SIZE]SIZE=2;[/SIZE]  
[SIZE=2]rectangle = sender [/SIZE][SIZE=2][COLOR=#0000ff]as[/COLOR][/SIZE][SIZE=2][COLOR=#2b91af]Rectangle[/COLOR][/SIZE][SIZE=2];[/SIZE]

[SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][SIZE=2] ([/SIZE][SIZE=2][COLOR=#0000ff]null[/COLOR][/SIZE][SIZE=2] != rectangle)[/SIZE]  
[SIZE=2]{[/SIZE]  
[SIZE=2][COLOR=#2b91af]ImageBrush[/COLOR][/SIZE][SIZE=2] ib = [/SIZE][SIZE=2][COLOR=#0000ff]new[/COLOR][/SIZE][SIZE=2][COLOR=#2b91af]ImageBrush[/COLOR][/SIZE]SIZE=2;[/SIZE]  
[SIZE=2]ib.ImageSource = [/SIZE][SIZE=2][COLOR=#0000ff]new[/COLOR][/SIZE][SIZE=2][COLOR=#2b91af]BitmapImage[/COLOR][/SIZE][SIZE=2]([/SIZE][SIZE=2][COLOR=#0000ff]new[/COLOR][/SIZE][SIZE=2][COLOR=#2b91af]Uri[/COLOR][/SIZE][SIZE=2]([/SIZE][SIZE=2][COLOR=#a31515]“Images/Sunset.jpg”[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#2b91af]UriKind[/COLOR][/SIZE][SIZE=2].Relative));[/SIZE]  
[SIZE=2]rectangle.Fill = ib;[/SIZE]

[SIZE=2][COLOR=#2b91af]Storyboard[/COLOR][/SIZE][SIZE=2].SetTarget(myDoubleAnimation, rectangle);[/SIZE]  
[SIZE=2][COLOR=#2b91af]Storyboard[/COLOR][/SIZE][SIZE=2].SetTargetProperty(myDoubleAnimation, [/SIZE][SIZE=2][COLOR=#0000ff]new[/COLOR][/SIZE][SIZE=2][COLOR=#2b91af]PropertyPath[/COLOR][/SIZE][SIZE=2] ([/SIZE][SIZE=2][COLOR=#a31515]"(rectangle.RenderTransform.Transform)"[/COLOR][/SIZE][SIZE=2]));[/SIZE]

[SIZE=2][COLOR=#2b91af]PropertyPath[/COLOR][/SIZE][SIZE=2] pp = [/SIZE][SIZE=2][COLOR=#0000ff]new[/COLOR][/SIZE][SIZE=2][COLOR=#2b91af]PropertyPath[/COLOR][/SIZE][SIZE=2]([/SIZE][SIZE=2][COLOR=#a31515]"(0).(1)"[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#0000ff]new[/COLOR][/SIZE][SIZE=2][COLOR=#2b91af]DependencyProperty[/COLOR][/SIZE][SIZE=2][] {[/SIZE]  
[SIZE=2][COLOR=#2b91af]Rectangle[/COLOR][/SIZE][SIZE=2].RenderTransformProperty, [/SIZE][SIZE=2][COLOR=#2b91af]RotateTransform[/COLOR][/SIZE][SIZE=2].AngleProperty });[/SIZE]

[SIZE=2]myDoubleAnimation.From = 0;[/SIZE]  
[SIZE=2]myDoubleAnimation.To = 360;[/SIZE]

[SIZE=2]myBorder.Resources.Add(rectangle.Name+[/SIZE][SIZE=2][COLOR=#a31515]“Animation”[/COLOR][/SIZE][SIZE=2], sb);[/SIZE]

[SIZE=2]sb.Begin();[/SIZE]

I’d be thankfull for any input :bounce:
