private void saveButton_Click(object sender, RoutedEventArgs e) { logEntry log = new logEntry(); log.Id = MainWindow.logEntries.Count + 1; log.Title = titleBox.Text; log.Text = entryBox.Text; log.EntryDate = DateTime.Now; MainWindow.logEntries.Add(log); }
private void deleteEntry_Click(object sender, RoutedEventArgs e) { // the if statement confirms that something is selected if (SelectedLogEntry != null) { // the reference to the selection within the grid is removed logEntries.Remove(SelectedLogEntry); // the reference is nullified SelectedLogEntry = null; } }
// Event of selection (when grid item clicked it is selected) private void gridLogEntries_SelectionChanged(object sender, SelectionChangedEventArgs e) { // row (selected item) within the data grid (gridLogEntries) cast within // the LogEntry class (adds functionality) SelectedLogEntry = (logEntry)gridLogEntries.SelectedItem; }