Catel.MVVM.Providers.WindowLogic.WindowLogic C# (CSharp) Method

WindowLogic() public method

Initializes a new instance of the WindowLogic class.
The is null.
public WindowLogic ( IView targetWindow, Type viewModelType = null, IViewModel viewModel = null ) : System
targetWindow IView The window this provider should take care of.
viewModelType System.Type Type of the view model.
viewModel IViewModel The view model to inject.
return System
        public WindowLogic(IView targetWindow, Type viewModelType = null, IViewModel viewModel = null)
            : base(targetWindow, viewModelType, viewModel)
        {
            var targetWindowType = targetWindow.GetType();

            string eventName;

            var closedEvent = targetWindowType.GetEventEx("Closed");
            if (closedEvent != null)
            {
                eventName = "Closed";

                _dynamicEventListener = new DynamicEventListener(targetWindow, "Closed", this, "OnTargetWindowClosed");
            }
            else
            {
                eventName = "Unloaded";

                _dynamicEventListener = new DynamicEventListener(targetWindow, "Unloaded", this, "OnTargetWindowClosed");
            }

            _targetWindowClosedEventName = eventName;

            Log.Debug("Using '{0}.{1}' event to determine window closing", targetWindowType.FullName, eventName);
        }
        #endregion