public UpdateWindow() { InitializeComponent(); // SetUiDefaults(); this.DataContextChanged += (s, e) => { _viewModelInteraction = e.NewValue as IViewModelInteraction; if (_viewModelInteraction != null) { _viewModelInteraction.ShowWindow = () => { return this.ShowDialog(); }; _viewModelInteraction.CloseWindow = () => { this.Dispatcher.Invoke(() => this.Close()); }; } }; }
public UpdatePropopsalViewModel(IViewModelInteraction viewModelInteraction ,UpdateManager updateManager, IProductUpdate productUpdate) { if (productUpdate == null) throw new ProductUpdateFailedException(new NullReferenceException("ProductUpdate!")); _viewModelInteraction = viewModelInteraction; _productUpdate = productUpdate; _updateManager = updateManager; _userInterfaceFactory = new UpdateUserInterfaceFactory(_updateManager); ShowUpdateInfo(); }
protected override void OnClosing(System.ComponentModel.CancelEventArgs e) { if (_viewModelInteraction != null) { // Close the main application because user tries to skip the update mechanism. if (_viewModelInteraction.ShutdownOnClose()) Environment.Exit(0); _viewModelInteraction.CloseWindow = null; _viewModelInteraction.ShowWindow = null; _viewModelInteraction = null; } base.OnClosing(e); }