private void _view_OnUpdateData(object sender, EventArgs e) { using (new WaitCursorHandler()) { ListDataGrid listDataGrid = null; if (sender is ListDataGrid) { listDataGrid = (ListDataGrid)sender; } else { listDataGrid = _view.ListDataGrid; } if (listDataGrid != null && listDataGrid.SelectedItem != null) { var model = _services.GetById(((UserModel)listDataGrid.SelectedItem).id); if (model != null) { var view = new UserEntryView(false, model); view.OnSaveData += UserEntryView_OnSaveData; view.ShowDialog(); } } } }
private void _view_OnCreateData(object sender, EventArgs e) { var view = new UserEntryView(); view.OnSaveData += UserEntryView_OnSaveData; view.ShowDialog(); }
private Task <string> GetUsernameAsync() { var source = new TaskCompletionSource <string>(); var window = new Window { Width = 300, Height = 200 }; var view = new UserEntryView(); window.Content = view; RoutedEventHandler handler = null; handler = (s, a) => { view.OkButton.Click -= handler; window.Close(); source.TrySetResult(view.UsernameTextBox.Text); }; view.OkButton.Click += handler; window.Show(); return(source.Task); }