c# - Scrolling Background Animation in WPF -


this code:

<drawingbrush viewport="0,0,16,16" viewportunits="absolute" stretch="none" tilemode="tile" x:key="dbcheckerboard">     <drawingbrush.drawing>         <drawinggroup>             <geometrydrawing brush="lightgray">                 <geometrydrawing.geometry>                     <geometrygroup>                         <rectanglegeometry rect="0,0,8,8"/>                         <rectanglegeometry rect="8,8,8,8"/>                     </geometrygroup>                 </geometrydrawing.geometry>             </geometrydrawing>             <geometrydrawing brush="white">                 <geometrydrawing.geometry>                     <geometrygroup>                         <rectanglegeometry rect="8,0,8,8"/>                         <rectanglegeometry rect="0,8,8,8"/>                     </geometrygroup>                 </geometrydrawing.geometry>             </geometrydrawing>         </drawinggroup>     </drawingbrush.drawing> </drawingbrush> 

which gives control element following background:

now want gently scroll background looks animated, can tell me how do that?

you try adding:

<controlname.triggers>     <eventtrigger routedevent="controlname.loaded">         <beginstoryboard>             <storyboard>                 <rectanimation                     storyboard.targetproperty="background.viewport"                     from="0 0 16 16" to="16 16 16 16" duration="0:0:1"                     repeatbehavior="forever" />             </storyboard>         </beginstoryboard>     </eventtrigger> </controlname.triggers> 

to control of controlname drawing brush used on (assuming it's used background).

if wanted make bit more automatic try creating style combines two:

<style x:key="scrollinggridstyle" targettype="control">     <setter property="background">         <setter.value>             <drawingbrush                 ... grid background brush                 ...         </setter.value>     </setter>     <style.triggers>         <eventtrigger routedevent="control.loaded">             <beginstoryboard>                 <storyboard>                     <rectanimation                         storyboard.targetproperty="background.viewport"                         from="0 0 16 16" to="16 16 16 16" duration="0:0:1"                         repeatbehavior="forever" />                 </storyboard>             </beginstoryboard>         </eventtrigger>     </style.triggers> </style> 

and use like:

<textblock style="{staticresource scrollinggridstyle}"/> 

or, add existing styles like:

<style targettype="textbox"         x:key="myprettytextbox"         basedon="{staticresource scrollinggridstyle}"> 

unfortunately, wpf doesn't have support creating composite styles.


Comments

Popular posts from this blog

jQuery Mobile app not scrolling in Firefox -

c++ - How to add Crypto++ library to Qt project -

how to receive file in java(servlet/jsp) -