Beispiel #1
0
        ///<summary>
        ///     Initiate the processing for Loaded event broadcast starting at this node
        /// </summary>
        /// <remarks>
        ///     This method is to allow firing Loaded event from a Helper class since the override is protected
        /// </remarks>
        internal void FireLoadedOnDescendentsInternal()
        {
            // This is to prevent duplicate Broadcasts for the Loaded event
            if (LoadedPending == null)
            {
                DependencyObject parent = Parent;

                if (parent == null)
                {
                    parent = VisualTreeHelper.GetParent(this);
                }


                // Check if this Loaded cancels against a previously queued Unloaded event
                // Note that if the Loaded and the Unloaded do not change the position of
                // the node within the loagical tree they are considered to cancel each other out.
                object[] unloadedPending = UnloadedPending;
                if (unloadedPending == null || unloadedPending[2] != parent)
                {
                    // Add a callback to the MediaContext which will be called
                    // before the first render after this point
                    BroadcastEventHelper.AddLoadedCallback(this, parent);
                }
                else
                {
                    // Dequeue Unloaded
                    BroadcastEventHelper.RemoveUnloadedCallback(this, unloadedPending);
                }
            }
        }