private object GetSetterValue(DependencyProperty property)
        {
            var setter = Setters.OfType <Setter>().FirstOrDefault(s => s.Property == property);

            if (setter == null && BasedOn != null)
            {
                setter = BasedOn.Setters.OfType <Setter>().FirstOrDefault(s => s.Property == property);
            }
            return(setter != null ? setter.Value : null);
        }
Beispiel #2
0
 internal void SetActive(bool active)
 {
     if (Element == null)
     {
         return;
     }
     if (_isInitializing)
     {
         afterInit = () => SetActive(active);
         return;
     }
     if (Storyboard != null && lastState != active)
     {
         if (active)
         {
             var state = storyboardStateInvalidated ? Storyboard.GetCurrentState(Element) : System.Windows.Media.Animation.ClockState.Stopped;
             //TimeSpan ? location = !storyboardStateInvalidated ? null : Storyboard.GetCurrentTime(Element);
             if (state == System.Windows.Media.Animation.ClockState.Stopped)
             {
                 Storyboard.Begin(Element, true);
             }
         }
         else
         {
             if (storyboardStateInvalidated)
             {
                 //Storyboard.Seek(TimeSpan.Zero);
                 Storyboard.Stop(Element);
             }
         }
     }
     if (active)
     {
         foreach (var setter in Setters.OfType <Setter>())
         {
             DependencyProperty property   = setter.Property;
             object             value      = setter.Value;
             string             targetName = setter.TargetName;
             var target = this.Element.FindName(targetName) as DependencyObject;
             target?.SetValue(property, value);
         }
     }
     lastState = active;
 }