/// <summary> /// add the textbox info to pirates collection by clicking add button /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Add_Click_1(object sender, RoutedEventArgs e) { if ((InsertBox.Text == String.Empty || ShipBox.Text == String.Empty || HomeBox.Text == String.Empty)) { MessageBox.Show("Enter Pirate Name Please.", "Error"); } else { ((MainViewModel)DataContext).AddPirates((InsertBox.Text), (ShipBox.Text), HomeBox.Text); InsertBox.Clear(); ShipBox.Clear(); HomeBox.Clear(); } }
/// <summary> /// checks textbox for being empty and inputs pirate information if not /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void HomeBox_KeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Enter) { if ((InsertBox.Text == String.Empty || ShipBox.Text == String.Empty || HomeBox.Text == String.Empty)) { MessageBox.Show("Enter Pirate Information Please.", "Error"); } else { ((MainViewModel)DataContext).AddPirates((InsertBox.Text), ShipBox.Text, HomeBox.Text); } InsertBox.Clear(); ShipBox.Clear(); HomeBox.Clear(); } }