c# - Animation not Behaving Itself -
i have statusbar
textblock
item. show process being under taken , status/information messages. if message not 'ready' want text fade away on time, leaving 'ready' when has gone.
i testing this, , have following xaml textblock
.
<statusbaritem dockpanel.dock="left" margin="0,2,0,0"> <textblock text="{binding statusmessage}" margin="5,0,0,0" foreground="white"> <textblock.style> <style targettype="textblock"> <style.triggers> <datatrigger binding="{binding systemisready, notifyonsourceupdated=true, mode=twoway}" value="false"> <datatrigger.enteractions> <beginstoryboard> <storyboard> <doubleanimation storyboard.targetproperty="opacity" from="1.0" to="0.5" duration="0:0:1.5"/> </storyboard> </beginstoryboard> </datatrigger.enteractions> </datatrigger> <datatrigger binding="{binding systemisready, notifyonsourceupdated=true, mode=twoway}" value="true"> <setter property="opacity" value="1.0"/> </datatrigger> </style.triggers> </style> </textblock.style> </textblock> </statusbaritem>
the test method changes text , updates issytemready
if status equal 'ready'. binding working animation fade 0.5 opacity seems have fired before application shown , trigger set opacity 1 not working.
why animation/trigger not re-firing?
thanks time.
the animation not re-firing because timeline
still running, have stop storyboard
allow value reset.
you can use stopstoryboard
this, name storyboard
call stopstoryboard
in enteractions
of true datatrigger
example:
<textblock.style> <style targettype="{x:type textblock}"> <style.triggers> <datatrigger binding="{binding systemisready, mode=twoway, notifyonsourceupdated=true}" value="false"> <datatrigger.enteractions> <beginstoryboard name="fadeout"> <storyboard> <doubleanimation storyboard.targetproperty="opacity" from="1.0" to="0.5" duration="0:0:1.5"/> </storyboard> </beginstoryboard> </datatrigger.enteractions> </datatrigger> <datatrigger binding="{binding systemisready, mode=twoway, notifyonsourceupdated=true}" value="true"> <setter property="opacity" value="1.0"/> <datatrigger.enteractions> <stopstoryboard beginstoryboardname="fadeout" /> </datatrigger.enteractions> </datatrigger> </style.triggers> </style> </textblock.style>