public MainWindow(IInteractionService interactions) { InitializeComponent(); ViewModel = Application.Current // get the bootstrapper from App resources .FindResource("MainWindowViewModel") as IMainWindowViewModel; this.interactions = interactions ?? Locator.Current.GetService <IInteractionService>(); IDisposable activation = null; activation = this.WhenActivated(disposables => { activation .DisposeWith(disposables); this // ViewModel -> DataContext .WhenAnyValue(v => v.ViewModel) .BindTo(this, v => v.DataContext) .DisposeWith(disposables); this // KeyDown -> ViewModel.KeyDown .WhenAnyValue(v => v.ViewModel) .Select(_ => this.Events().KeyDown) .BindTo(ViewModel, vm => vm.KeyDown) .DisposeWith(disposables); this // Handle GetNodeColor interaction .interactions .GetNodeColor .RegisterHandler(async interaction => { var dialog = new ColorDialog { Color = interaction.Input // dialog edits what the node sent here }; await this.ShowMetroDialogAsync(dialog); var isAccepted = await dialog.WaitUntilClosedAsync(); await this.HideMetroDialogAsync(dialog); if (isAccepted) { interaction.SetOutput(dialog.Color); // return new color } else { interaction.SetOutput(interaction.Input); // return old color } }) .DisposeWith(disposables); this .interactions .GetNodeOperation .RegisterHandler(async interaction => { var dialog = new OperationDialog { Operation = interaction.Input // dialog edits what the node sent here }; await this.ShowMetroDialogAsync(dialog); var isAccepted = await dialog.WaitUntilClosedAsync(); await this.HideMetroDialogAsync(dialog); if (isAccepted) { interaction.SetOutput(dialog.Operation); // return new operation } else { interaction.SetOutput(interaction.Input); // return old operation } }) .DisposeWith(disposables); }); }