c# - Custom Animation Port to Universal App from WP7 fails with SetTargetProperty -


porting custom animation code wp7 store app. wp7 code performed page flip animation of border object bunch of text boxes on (that page flipped.) in below code storyboard.settargetproperty not compile complaining wants string:

doubleanimation anima = new doubleanimation {     = pagehostbaseindex + 1,     duration = calculatefractionalduration(pagehostbaseindex + 1)         };  storyboard storyboard = new storyboard(); storyboard.settarget(anima, this.pagetransition); storyboard.settargetproperty(anima, new propertypath(pagetransition.fractionalbaseindexproperty));  storyboard.children.add(anima); storyboard.completed += storyboard_completed;  storyboard.begin(); 

pagetransition derives dependencyobject, contains dependencyproperty called fractionalbaseindexproperty.

i tried putting in string "pagetransition.fractionalbaseindexproperty" constructing propertypath string. tried "(pagetransition).(fractionalbaseindexproperty)" these compile fail exception:

no installed components detected. cannot resolve targetproperty pagetransition.fractionalbaseindexproperty on specified object. @ windows.ui.xaml.media.animation.storyboard.begin()

i tried enabledependentanimation = true, , making pagetransition derive timeline instead of dependencyobeject these had no effect (same error.) eventual animation little complex don't think it's getting far. seems silverlight universal difference in objects acceptable binding storyboard or in path. i'll bet there's more xaml friendly way @ point i'm trying minimize port , i'd keep feel of animation.

thoughts?

after hours of tinkering , searching , reverting of previous tinkerings got past this. thread got me thinking:

windows 8 - animating custom property in code-behind.

my border objects declared in xaml storyboard, animation , pagetransition objs weren’t. added following xaml in usercontrol.resources:

<storyboard x:name="storyboard">     <doubleanimation x:name="anima">     </doubleanimation>             </storyboard> <local:fliptransition x:key="foo"></local:fliptransition> 

i used fliptransition because in case pagetransition abstract class (so xaml wouldn’t let me instantiate it.) fliptranstion derives pagetransition.

along had re-create new storyboards , animation objects (see below) same names ones in above xaml (i don’t know why ones instantiated in xaml wouldn’t work.)

i had set enabledependentanimation = true

and last, path in settargetproperty had change pagetransition. fractionalbaseindex (instead of original pagetransition.fractionalbaseindexproperty.)

doubleanimation anima = new doubleanimation {     = pagehostbaseindex + 1,     duration = calculatefractionalduration(pagehostbaseindex + 1),     enabledependentanimation = true }; storyboard storyboard = new storyboard();  storyboard.settarget(anima, this.pagetransition); storyboard.settargetproperty(anima, "pagetransition.fractionalbaseindex"); 

when these came worked.


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -