WPF Animation of DataGridRow Background color from transparent to "Current" (current is set with Trigger) -


i'm setting datagridrow backgroundcolor green or red trigger based on logerror value.

i want animate newly added rows transparency.

this works fine:

from="transparent" to="red" 

but want color goes current color set style. not red green well.

this not work:

from="transparent" to="{templatebinding datagridrow.background}" 

or

from="transparent" to="{binding relativesource={relativesource self}, path=backgound}" 

code:

<datagrid.resources>   <style targettype="{x:type datagridrow}">     <setter property = "background" value="limegreen"/>     <style.triggers>       <datatrigger binding="{binding logmessage}" value="exception has occured">         <setter property = "background" value="red"/>       </datatrigger>     </style.triggers>   </style> </datagrid.resources>           <datagrid.rowstyle>   <style targettype="datagridrow">     <style.triggers>       <eventtrigger routedevent="loaded">         <beginstoryboard>           <storyboard>             <coloranimation                 storyboard.targetproperty="(datagridrow.background).(solidcolorbrush.color)"                  duration="00:00:03"                  from="transparent"                 to="{templatebinding datagridrow.background}"/>           </storyboard>         </beginstoryboard>       </eventtrigger>     </style.triggers>   </style> </datagrid.rowstyle> 

error message: cannot freeze storyboard timeline tree use across threads.

there few problems in xaml code.

first, have specified default style under resources section of datagrid , later provide own style override default style. either should define new style , set basedon dp refer default style. in case don't see any use of defining separate style trigger.

second, want animation go transparent colour selected in style can either limegreen or red depending on trigger. so, should not set to value in animation since automatically picked up.

this work desire -

   <datagrid>       <datagrid.resources>           <style targettype="{x:type datagridrow}">               <setter property ="background" value="limegreen"/>               <style.triggers>                  <datatrigger binding="{binding logmessage}"                                         value="exception has occured">                      <setter property = "background" value="red"/>                  </datatrigger>                  <eventtrigger routedevent="loaded">                      <beginstoryboard>                          <storyboard>                              <coloranimation storyboard.targetproperty=                               "(datagridrow.background).(solidcolorbrush.color)"                                               duration="00:00:03"                                               from="transparent"/>                          </storyboard>                      </beginstoryboard>                  </eventtrigger>                </style.triggers>             </style>         </datagrid.resources>    </datagrid> 

Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -