public void InitProgressable(IProgressable progress) { ProgressViewModel.InitProgressable(progress); CancelButton.Click += (sender, e) => { if (!progress.IsCompleted) { progress.Cancel(); } }; Closed += (sender, e) => { if (!progress.IsCompleted) { progress.Cancel(); } }; }