public TimeSpan?ShowDialog(TimeSpan initialValue) { dialogUI = new UpdateTimer(); dialogUI.Owner = System.Windows.Application.Current.MainWindow; var vm = dialogUI.DataContext as ViewModel.UpdateTimerVM; vm.DialogCompleted += DialogCompleted; vm.Timer = initialValue; if (true == dialogUI.ShowDialog()) { return(vm.Timer); } return(null); }