예제 #1
0
        ///<summary>
        ///     Broadcast Unloaded event starting at this node
        /// </summary>
        internal void FireUnloadedOnDescendentsInternal()
        {
            // This is to prevent duplicate Broadcasts for the Unloaded event
            if (UnloadedPending == null)
            {
                DependencyObject parent = Parent;

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


                // Check if this Unloaded cancels against a previously queued Loaded 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[] loadedPending = LoadedPending;
                if (loadedPending == null)
                {
                    // Add a callback to the MediaContext which will be called
                    // before the first render after this point
                    BroadcastEventHelper.AddUnloadedCallback(this, parent);
                }
                else
                {
                    // Dequeue Loaded
                    BroadcastEventHelper.RemoveLoadedCallback(this, loadedPending);
                }
            }
        }