private static void OnIsAnimatingChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
MetaPanelBase metaPanelBase = (MetaPanelBase)d;
// By always requesting a panel measure when the Rendering event is
// fired we ensure that the panel invokes the animation instances and
// the child elements are updated until the animation ends.
if ((bool)e.NewValue)
{
// Reset the last ticks as we do not want to use the duration since the
// last time animation finished, which might have been a long time ago
metaPanelBase._lastTicks = -1;
// This event is fired just before rendering of each display frame
CompositionTarget.Rendering += new EventHandler(metaPanelBase.OnRendering);
}
else
CompositionTarget.Rendering -= new EventHandler(metaPanelBase.OnRendering);
// Raise the changed event
EventHandler handler = metaPanelBase.IsAnimatingChanged;
if (handler != null)
handler(metaPanelBase, EventArgs.Empty);
}