@@ -37,6 +37,8 @@ public sealed partial class DetailsLayoutPage : BaseGroupableLayoutPage
3737 /// </summary>
3838 private uint currentIconSize ;
3939
40+ private RectangleSelection ? _rectangleSelection ;
41+
4042 // Properties
4143
4244 protected override ListViewBase ListViewBase => FileList ;
@@ -77,8 +79,8 @@ public DetailsLayoutPage() : base()
7779 {
7880 InitializeComponent ( ) ;
7981 DataContext = this ;
80- var selectionRectangle = RectangleSelection . Create ( FileList , SelectionRectangle , FileList_SelectionChanged ) ;
81- selectionRectangle . SelectionEnded += SelectionRectangle_SelectionEnded ;
82+ _rectangleSelection = RectangleSelection . Create ( FileList , SelectionRectangle , FileList_SelectionChanged ) ;
83+ _rectangleSelection . SelectionEnded += SelectionRectangle_SelectionEnded ;
8284
8385 UpdateSortOptionsCommand = new RelayCommand < string > ( x =>
8486 {
@@ -202,6 +204,11 @@ protected override void OnNavigatingFrom(NavigatingCancelEventArgs e)
202204 FolderSettings . SortOptionPreferenceUpdated -= FolderSettings_SortOptionPreferenceUpdated ;
203205 ParentShellPageInstance . ShellViewModel . PageTypeUpdated -= FilesystemViewModel_PageTypeUpdated ;
204206 UserSettingsService . LayoutSettingsService . PropertyChanged -= LayoutSettingsService_PropertyChanged ;
207+ if ( _rectangleSelection is not null )
208+ {
209+ _rectangleSelection . SelectionEnded -= SelectionRectangle_SelectionEnded ;
210+ _rectangleSelection = null ;
211+ }
205212 }
206213
207214 private void LayoutSettingsService_PropertyChanged ( object ? sender , PropertyChangedEventArgs e )
@@ -1053,4 +1060,4 @@ private static GitProperties GetEnabledGitProperties(ColumnsViewModel columnsVie
10531060 } ;
10541061 }
10551062 }
1056- }
1063+ }
0 commit comments