@@ -253,20 +253,27 @@ protected override void EndRename(TextBox textBox)
253
253
{
254
254
Popup ? popup = gridViewItem . FindDescendant ( "EditPopup" ) as Popup ;
255
255
TextBlock ? textBlock = gridViewItem . FindDescendant ( "ItemName" ) as TextBlock ;
256
- popup ! . IsOpen = false ;
257
- textBlock ! . Opacity = ( textBlock . DataContext as ListedItem ) ! . Opacity ;
256
+
257
+ if ( popup is not null )
258
+ popup . IsOpen = false ;
259
+
260
+ if ( textBlock is not null )
261
+ textBlock . Opacity = ( textBlock . DataContext as ListedItem ) ! . Opacity ;
258
262
}
259
263
else if ( FolderSettings . LayoutMode == FolderLayoutModes . TilesView )
260
264
{
261
265
TextBlock ? textBlock = gridViewItem . FindDescendant ( "ItemName" ) as TextBlock ;
266
+
262
267
textBox . Visibility = Visibility . Collapsed ;
263
- textBlock ! . Visibility = Visibility . Visible ;
268
+
269
+ if ( textBlock is not null )
270
+ textBlock . Visibility = Visibility . Visible ;
264
271
}
265
272
266
273
// Unsubscribe from events
267
274
if ( textBox is not null )
268
275
{
269
- textBox ! . LostFocus -= RenameTextBox_LostFocus ;
276
+ textBox . LostFocus -= RenameTextBox_LostFocus ;
270
277
textBox . KeyDown -= RenameTextBox_KeyDown ;
271
278
}
272
279
@@ -430,15 +437,17 @@ private async void FileList_ItemTapped(object sender, TappedRoutedEventArgs e)
430
437
if ( FolderSettings . LayoutMode == FolderLayoutModes . GridView )
431
438
{
432
439
Popup popup = gridViewItem . FindDescendant ( "EditPopup" ) as Popup ;
433
- var textBox = popup . Child as TextBox ;
440
+ var textBox = popup ? . Child as TextBox ;
434
441
435
- await CommitRenameAsync ( textBox ) ;
442
+ if ( textBox is not null )
443
+ await CommitRenameAsync ( textBox ) ;
436
444
}
437
445
else
438
446
{
439
447
var textBox = gridViewItem . FindDescendant ( "TileViewTextBoxItemName" ) as TextBox ;
440
448
441
- await CommitRenameAsync ( textBox ) ;
449
+ if ( textBox is not null )
450
+ await CommitRenameAsync ( textBox ) ;
442
451
}
443
452
}
444
453
}
0 commit comments