xaml - Metro Attach FadeInAnimation to an Image -


i've got following should work:

xaml

<window.resources>     <storyboard x:name="fadeinstoryboard1">         <fadeinthemeanimation storyboard.targetname="image1" />     </storyboard>     <storyboard x:name="fadeinstoryboard2">         <fadeinthemeanimation storyboard.targetname="image2" />     </storyboard>     <storyboard x:name="fadeinstoryboard3">         <fadeinthemeanimation storyboard.targetname="image3" />     </storyboard>     <storyboard x:name="fadeinstoryboard4">         <fadeinthemeanimation storyboard.targetname="image4" />     </storyboard>     <storyboard x:name="fadeinstoryboard5">         <fadeinthemeanimation storyboard.targetname="image5" />     </storyboard> </window.resources> <image source="../assets/image.png" x:name="image1" /> <image source="../assets/image.png" x:name="image2" /> <image source="../assets/image.png" x:name="image3" /> <image source="../assets/image.png" x:name="image4" /> <image source="../assets/image.png" x:name="image5" /> 

c#

//fades in plane image  private void fadein(int index) {     if (index == 0)         fadeinstoryboard1.begin();     else if (index == 1)         fadeinstoryboard2.begin();     else if (index == 2)         fadeinstoryboard3.begin();     else if (index == 3)         fadeinstoryboard4.begin();     else         fadeinstoryboard5.begin(); } 

the above code works - there's got better way. there way either (a) put storyboard objects list can access index, or (b) attach storyboard object image object target?

is iterating through resources , checking name option?

string name = "fadeinstoryboard" + index; foreach (object resource in this.resources) {     if (resource system.windows.media.animation.storyboard)     {         system.windows.media.animation.storyboard storyboard = (system.windows.media.animation.storyboard)resource;         if (storyboard.name == name) storyboard.begin();      }   } 

if had pattern in keys, use

this.resources.findbyname("mykey"+index) 

Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

.htaccess - Matching full URL in RewriteCond -