private void RenameNote(object sender, RoutedEventArgs e) { int noteId = int.Parse(((TextBlock)((StackPanel)((Border)((Grid) ((TextBox)sender).Parent).Parent).Parent).Children[0]).Text); if (!engin.RenameNote(noteId)) { MessageBox.Show("A problem occured while saving the note. There might be problem with the note's file"); } }