예제 #1
0
 internal IEnumerable <Tuple <DependencyObject, DependencyProperty, int?> > GoThroughElementsToAccessProperty(PropertyPath propertyPath, DependencyObject targetBeforePath)
 {
     foreach (Tuple <DependencyObject, DependencyProperty, int?> element in propertyPath.INTERNAL_AccessPropertyContainer(targetBeforePath))
     {
         yield return(element);
     }
     yield break;
 }
예제 #2
0
        internal void GetTargetElementAndPropertyInfo(
            DependencyObject targetParent,
            out DependencyObject target,
            out PropertyPath propertyPath,
            bool isTargetParentTheTarget = false)
        {
            propertyPath = Storyboard.GetTargetProperty(this);

            DependencyObject targetBeforePath;

            if (!isTargetParentTheTarget) // "isTargetParentTheTarget" is used when running the Storyboard programmatically via Begin(), because in that case the target is defined at the storyboard level.
            {
                // First, see if the target element is already known:
                targetBeforePath = Storyboard.GetTarget(this);

                // If not, look for it based on its name:
                if (targetBeforePath == null)
                {
                    string targetName = Storyboard.GetTargetName(this);
                    if (targetParent is FrameworkElement fe)
                    {
                        targetBeforePath = (DependencyObject)fe.FindName(targetName);
                        if (targetBeforePath == null && targetParent is Control control)
                        {
                            targetBeforePath = control.GetTemplateChild(targetName);
                        }
                    }
                }
            }
            else
            {
                targetBeforePath = targetParent;
            }

            target = targetBeforePath;
            foreach (Tuple <DependencyObject, DependencyProperty, int?> element in propertyPath.INTERNAL_AccessPropertyContainer(targetBeforePath))
            {
                target = element.Item1;
            }
        }