xaml - How to animate Windows Phone 8.1 AppBar background color? -


i can't seem background color of appbar animate using coloranimation.

<storyboard x:name="fadecolorstoryboard">     <coloranimation         storyboard.targetname="bar"         storyboard.targetproperty="(control.background).(solidcolorbrush.color)"         from="yellow" to="green" duration="0:0:1" /> </storyboard> 

i've tested storyboard animating foreground color of textblock , works. there any way can animate appbar's background color?

i've tried using custom attached property change background color, can't set targetproperty of storyboard custom attached property, unlike in silverlight.

ok, figured out solution. it's not best solution, want. i'd still interested if there better way, this'll now.

edit: forgot mention, requires enabledependentanimation on coloranimation set true reason.

i subclassed commandbar , added own backgroundcolor property can animated.

class commandbarex : commandbar {     public color backgroundcolor     {         { return (color)getvalue(backgroundcolorproperty); }         set { setvalue(backgroundcolorproperty, value); }     }      public static readonly dependencyproperty backgroundcolorproperty =         dependencyproperty.register("backgroundcolor", typeof(color), typeof(commandbarex), new propertymetadata(colors.gray, onbackgroundcolorpropertychanged));      static void onbackgroundcolorpropertychanged(dependencyobject d, dependencypropertychangedeventargs e)     {         var bar = d commandbarex;         if (bar == null)             return;          var brush = bar.background solidcolorbrush;         if (brush == null)         {             bar.background = new solidcolorbrush((color)e.newvalue);         }         else         {             brush.color = (color)e.newvalue;             bar.background = brush;  // force property change event         }     } } 

Comments