private void ShareButtonClicked(object sender, EventArgs e) { ShareDialog shareDialog = new ShareDialog(); ShareViewModel shareViewModel = new ShareViewModel(sender as CardDeck); shareViewModel.ErrorOccured += (s, args) => { MessageBox.Show(args.GetException().Message); shareViewModel.CloseForm.Execute(null); }; shareDialog.DataContext = shareViewModel; shareDialog.Owner = App.Current.MainWindow; shareDialog.ShowDialog(); }