private void AuthorSelectorLB_SelectionChanged(object sender, SelectionChangedEventArgs e) { SelectedAuthor = _authorTable.ConvertDataRowToAuthor(_authors[AuthorSelectorLB.SelectedIndex]); TB_SelectAuthorFirstName.Text = SelectedAuthor.FirstName; TB_SelectAuthorLastName.Text = SelectedAuthor.LastName; TB_SelectAuthorMiddleName.Text = SelectedAuthor.MiddleName; Close(); }
private void AuthorsDataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e) { DataGrid dataGrid = sender as DataGrid; DataGridRow row = (DataGridRow)dataGrid.ItemContainerGenerator.ContainerFromIndex(dataGrid.SelectedIndex); DataGridCell RowColumn = dataGrid.Columns[1].GetCellContent(row).Parent as DataGridCell; string LastName = ((TextBlock)RowColumn.Content).Text; RowColumn = dataGrid.Columns[2].GetCellContent(row).Parent as DataGridCell; string FirstName = ((TextBlock)RowColumn.Content).Text; DataRow[] _authors = _authorTableModel.FindAuthors(LastName, FirstName); _selectedAuthor = _authorTableModel.ConvertDataRowToAuthor(_authors[0]); }