wpf - Set DoubleAnimation with Binding to an external object -


i have following style contains animation used expand border:

<style targettype="{x:type border}" x:key="borderanimations">     <setter property="flowdirection" value="righttoleft" />     <style.triggers>         <eventtrigger routedevent="mouseenter">             <beginstoryboard>                 <storyboard >                     <doubleanimation                         storyboard.targetproperty="width"                         begintime="0:0:0"                         from="" to="420" duration="0:0:0.2" />                 </storyboard>             </beginstoryboard>         </eventtrigger>         <eventtrigger routedevent="mouseleave">             <beginstoryboard>                 <storyboard >                     <doubleanimation                         storyboard.targetproperty="width"                         begintime="0:0:0"                         from="420" to="90" duration="0:0:0.2" />                 </storyboard>             </beginstoryboard>         </eventtrigger>     </style.triggers> </style> 

i want set from property generics' button width. here have generic button style:

 <style targettype="{x:type button}">     <setter property="foreground" value="white" />     <setter property="fontsize" value="80" />     <setter property="horizontalalignment" value="right"/>     <setter property="verticalalignment" value="center" />     <setter property="background" value="{dynamicresource mainblue}" />     <setter property="height" value="{binding                  elementname=mainucpanel, path=height,                  converter={staticresource arithmeticconverter},                  converterparameter=int32.parse(values[0]) / 6}" />     <setter property="width" value="{binding path=height, relativesource={relativesource self}}" />     <setter property="datacontext" value="{binding relativesource={relativesource findancestor, ancestortype={x:type view:desktopucmain}}, path=datacontext}" />     <setter property="template">         <setter.value>             <controltemplate targettype="{x:type button}">                 <border background="{templatebinding background}" borderbrush="transparent" borderthickness="0" cornerradius="5" x:name="bd">                     <contentpresenter horizontalalignment="{templatebinding horizontalcontentalignment}"                      margin="5" verticalalignment="{templatebinding verticalcontentalignment}"                      snapstodevicepixels="{templatebinding snapstodevicepixels}" recognizesaccesskey="true"/>                 </border>             </controltemplate>         </setter.value>     </setter>     <style.triggers>         <trigger property="ismouseover" value="true">             <setter property="cursor" value="hand" />             <trigger.exitactions>                 <beginstoryboard>                     <storyboard>                         <coloranimation storyboard.targetproperty="(button.background).(solidcolorbrush.color)" to="#ff1e90ff" duration="0:0:0.2" />                     </storyboard>                 </beginstoryboard>             </trigger.exitactions>             <trigger.enteractions>                 <beginstoryboard>                     <storyboard>                         <coloranimation storyboard.targetproperty="(button.background).(solidcolorbrush.color)" to="#27ace3" duration="0:0:0.2" />                     </storyboard>                 </beginstoryboard>             </trigger.enteractions>         </trigger>     </style.triggers> </style> 

i've tried set as:

from="{binding relativesource={relativesource ancestortype={x:type button}}, path=actualwidth}" 

but it's not working...

note: these styles located on resourcedictionary.xaml. how can achieve animation width?

edit: thrown exception:

cannot freeze storyboard timeline tree use across threads. 


Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -