/// <summary>
        ///     Broadcast the Loaded/Unloaded event in the sub-tree starting at the given root
        /// </summary>
        /// <param name="root">
        ///     Root of the sub-tree that the event will be broadcast to
        /// </param>
        /// <param name="routedEvent">
        ///     RoutedEventID for the event we wish to broadcast
        /// </param>
        private static void BroadcastEvent(DependencyObject root, RoutedEvent routedEvent)
        {
            // Broadcast to the tree and collect the set of nodes
            // on which we need fire the Loaded event
            List <DependencyObject> eventRoute = new List <DependencyObject>();

            // Create a DescendentsWalker for the broadcast
            DescendentsWalker <BroadcastEventData> walker = new DescendentsWalker <BroadcastEventData>(
                TreeWalkPriority.VisualTree, BroadcastDelegate, new BroadcastEventData(root, routedEvent, eventRoute));

            // Start the walk down
            walker.StartWalk(root);

            // Iterate and raise the event on each of the nodes in the tree
            for (int i = 0; i < eventRoute.Count; i++)
            {
                DependencyObject d    = eventRoute[i];
                RoutedEventArgs  args = new RoutedEventArgs(routedEvent, d);
                FrameworkObject  fo   = new FrameworkObject(d, true /*throwIfNeither*/);

                if (routedEvent == FrameworkElement.LoadedEvent)
                {
                    fo.OnLoaded(args);
                }
                else
                {
                    fo.OnUnloaded(args);
                }
            }
        }
Esempio n. 2
0
        // Token: 0x06000C67 RID: 3175 RVA: 0x0002E60C File Offset: 0x0002C80C
        internal static void InvalidateOnResourcesChange(FrameworkElement fe, FrameworkContentElement fce, ResourcesChangeInfo info)
        {
            FrameworkObject frameworkObject = new FrameworkObject(fe, fce);

            frameworkObject.Reset(frameworkObject.TemplatedParent);
            frameworkObject.HasTemplateChanged = false;
            DependencyObject dependencyObject = (fe != null) ? fe : fce;

            if (TreeWalkHelper.HasChildren(fe, fce))
            {
                DescendentsWalker <ResourcesChangeInfo> descendentsWalker = new DescendentsWalker <ResourcesChangeInfo>(TreeWalkPriority.LogicalTree, TreeWalkHelper.ResourcesChangeDelegate, info);
                descendentsWalker.StartWalk(dependencyObject);
                return;
            }
            TreeWalkHelper.OnResourcesChanged(dependencyObject, info, true);
        }
Esempio n. 3
0
        // Token: 0x06000C6C RID: 3180 RVA: 0x0002EB1C File Offset: 0x0002CD1C
        internal static void InvalidateOnInheritablePropertyChange(FrameworkElement fe, FrameworkContentElement fce, InheritablePropertyChangeInfo info, bool skipStartNode)
        {
            DependencyProperty property        = info.Property;
            FrameworkObject    frameworkObject = new FrameworkObject(fe, fce);

            if (TreeWalkHelper.HasChildren(fe, fce))
            {
                DependencyObject @do = frameworkObject.DO;
                DescendentsWalker <InheritablePropertyChangeInfo> descendentsWalker = new DescendentsWalker <InheritablePropertyChangeInfo>(TreeWalkPriority.LogicalTree, TreeWalkHelper.InheritablePropertyChangeDelegate, info);
                descendentsWalker.StartWalk(@do, skipStartNode);
                return;
            }
            if (!skipStartNode)
            {
                bool visitedViaVisualTree = false;
                TreeWalkHelper.OnInheritablePropertyChanged(frameworkObject.DO, info, visitedViaVisualTree);
            }
        }
        // Token: 0x0600030C RID: 780 RVA: 0x00008740 File Offset: 0x00006940
        private static void BroadcastEvent(DependencyObject root, RoutedEvent routedEvent)
        {
            List <DependencyObject> list = new List <DependencyObject>();
            DescendentsWalker <BroadcastEventHelper.BroadcastEventData> descendentsWalker = new DescendentsWalker <BroadcastEventHelper.BroadcastEventData>(TreeWalkPriority.VisualTree, BroadcastEventHelper.BroadcastDelegate, new BroadcastEventHelper.BroadcastEventData(root, routedEvent, list));

            descendentsWalker.StartWalk(root);
            for (int i = 0; i < list.Count; i++)
            {
                DependencyObject dependencyObject = list[i];
                RoutedEventArgs  args             = new RoutedEventArgs(routedEvent, dependencyObject);
                FrameworkObject  frameworkObject  = new FrameworkObject(dependencyObject, true);
                if (routedEvent == FrameworkElement.LoadedEvent)
                {
                    frameworkObject.OnLoaded(args);
                }
                else
                {
                    frameworkObject.OnUnloaded(args);
                }
            }
        }