Catel.Services.UIVisualizerService.HandleCloseSubscription C# (CSharp) Method

HandleCloseSubscription() protected method

Handles the close subscription. The default implementation uses the DynamicEventListener.
protected HandleCloseSubscription ( object window, object data, EventHandler completedProc, bool isModal ) : void
window object The window.
data object The data that will be set as data context.
completedProc EventHandler The completed callback.
isModal bool True if this is a ShowDialog request.
return void
        protected virtual void HandleCloseSubscription(object window, object data, EventHandler<UICompletedEventArgs> completedProc, bool isModal)
        {
            var dynamicEventListener = new DynamicEventListener(window, "Closed");

            EventHandler closed = null;
            closed = (sender, e) =>
            {
                bool? dialogResult = null;
                PropertyHelper.TryGetPropertyValue(window, "DialogResult", out dialogResult);

                completedProc(this, new UICompletedEventArgs(data, isModal ? dialogResult : null));
#if SILVERLIGHT     
                if (window is ChildWindow)
                {
                    // Due to a bug in the latest version of the Silverlight toolkit, set parent to enabled again
                    // TODO: After every toolkit release, check if this code can be removed
                    Application.Current.RootVisual.SetValue(Control.IsEnabledProperty, true);
                }
#endif
                dynamicEventListener.EventOccurred -= closed;
                dynamicEventListener.UnsubscribeFromEvent();
            };

            dynamicEventListener.EventOccurred += closed;
        }