示例#1
0
        private void RemoveAllHandledEvents()
        {
            if (Shown != null)
            {
                foreach (var @delegate in Shown.GetInvocationList())
                {
                    var h = (EventHandler)@delegate;
                    Shown -= h;
                }
            }

            if (Closing != null)
            {
                foreach (var @delegate in Closing.GetInvocationList())
                {
                    var h = (CancelEventHandler)@delegate;
                    Closing -= h;
                }
            }

            if (Closed != null)
            {
                foreach (var @delegate in Closed.GetInvocationList())
                {
                    var h = (EventHandler)@delegate;
                    Closed -= h;
                }
            }

            var p = Parent as FrameworkElement;

            if (p != null)
            {
                p.DataContextChanged -= Parent_DataContextChanged;
            }
        }