示例#1
0
        public override IDataTriggerCondition CreateDataTriggerCondition(FrameworkElement element)
        {
            if (Property == null)
            {
                throw new Granular.Exception("Trigger.Property cannot be null");
            }

            DependencyProperty dependencyProperty = Property.GetDependencyProperty(element.GetType());

            object resolvedValue = Value == null || dependencyProperty.PropertyType.IsInstanceOfType(Value) ? Value : TypeConverter.ConvertValue(Value.ToString(), dependencyProperty.PropertyType, XamlNamespaces.Empty, null);

            FrameworkElement source = SourceName.IsNullOrEmpty() ? element : NameScope.GetTemplateNameScope(element).FindName(SourceName) as FrameworkElement;

            return(TriggerCondition.Register(source, dependencyProperty, resolvedValue));
        }
示例#2
0
        private void StartNewStoryboard(Storyboard newStoryboard)
        {
            if (newStoryboard != null)
            {
                newStoryboard.Begin(container, NameScope.GetTemplateNameScope(container));

                if (currentStoryboard != null)
                {
                    currentStoryboard.Stop(container);
                }
            }
            else if (currentStoryboard != null)
            {
                currentStoryboard.Remove(container);
            }

            currentStoryboard = newStoryboard;
        }
示例#3
0
 private static FrameworkElement GetResolvedTarget(FrameworkElement target, string targetName, BaseValueSource valueSource)
 {
     return(targetName.IsNullOrEmpty() ? target : (valueSource == BaseValueSource.Local ? NameScope.GetContainingNameScope(target) : NameScope.GetTemplateNameScope(target)).FindName(targetName) as FrameworkElement);
 }