@@ -251,9 +251,14 @@ private void AllView_PreparingCellForEdit(object sender, DataGridPreparingCellFo
251
251
252
252
if ( AppSettings . DoubleTapToRenameFiles == false ) // Check if the double tap to rename files setting is off
253
253
{
254
- AllView . CancelEdit ( ) ; // Cancel the edit operation
255
- App . CurrentInstance . InteractionOperations . OpenItem_Click ( null , null ) ; // Open the file instead
256
- return ;
254
+ // Only cancel if this event was triggered by a tap
255
+ // Do not cancel when user presses F2 or context menu
256
+ if ( e . EditingEventArgs is TappedRoutedEventArgs )
257
+ {
258
+ AllView . CancelEdit ( ) ; // Cancel the edit operation
259
+ App . CurrentInstance . InteractionOperations . OpenItem_Click ( null , null ) ; // Open the file instead
260
+ return ;
261
+ }
257
262
}
258
263
259
264
int extensionLength = SelectedItem . FileExtension ? . Length ?? 0 ;
@@ -288,7 +293,7 @@ private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
288
293
289
294
private async void AllView_CellEditEnding ( object sender , DataGridCellEditEndingEventArgs e )
290
295
{
291
- if ( e . EditAction == DataGridEditAction . Cancel )
296
+ if ( e . EditAction == DataGridEditAction . Cancel || renamingTextBox == null )
292
297
{
293
298
return ;
294
299
}
@@ -308,7 +313,10 @@ private async void AllView_CellEditEnding(object sender, DataGridCellEditEndingE
308
313
309
314
private void AllView_CellEditEnded ( object sender , DataGridCellEditEndedEventArgs e )
310
315
{
311
- renamingTextBox . TextChanged -= TextBox_TextChanged ;
316
+ if ( renamingTextBox != null )
317
+ {
318
+ renamingTextBox . TextChanged -= TextBox_TextChanged ;
319
+ }
312
320
FileNameTeachingTip . IsOpen = false ;
313
321
isRenamingItem = false ;
314
322
}
0 commit comments