@@ -23,7 +23,12 @@ public sealed partial class GridLayoutPage : BaseGroupableLayoutPage
2323 {
2424 // Fields
2525
26+ /// <summary>
27+ /// This reference is used to prevent unnecessary icon reloading by only reloading icons when their
28+ /// size changes, even if the layout size changes (since some layout sizes share the same icon size).
29+ /// </summary>
2630 private uint currentIconSize ;
31+
2732 private volatile bool shouldSetVerticalScrollMode ;
2833
2934 // Properties
@@ -42,6 +47,14 @@ public int RowHeightListView
4247 get => LayoutSizeKindHelper . GetListViewRowHeight ( UserSettingsService . LayoutSettingsService . ListViewSize ) ;
4348 }
4449
50+ /// <summary>
51+ /// Icon Box size in the List View layout. The value is increased by 4px to account for icon overlays.
52+ /// </summary>
53+ public int IconBoxSizeListView
54+ {
55+ get => ( int ) ( LayoutSizeKindHelper . GetIconSize ( FolderLayoutModes . ListView ) + 4 ) ;
56+ }
57+
4558 /// <summary>
4659 /// Item width in the Tiles View layout
4760 /// </summary>
@@ -127,7 +140,7 @@ protected override void OnNavigatedTo(NavigationEventArgs eventArgs)
127140
128141 base . OnNavigatedTo ( eventArgs ) ;
129142
130- currentIconSize = FolderSettings . GetRoundedIconSize ( ) ;
143+ currentIconSize = LayoutSizeKindHelper . GetIconSize ( FolderSettings . LayoutMode ) ;
131144
132145 FolderSettings . LayoutModeChangeRequested -= FolderSettings_LayoutModeChangeRequested ;
133146 FolderSettings . LayoutModeChangeRequested += FolderSettings_LayoutModeChangeRequested ;
@@ -162,35 +175,34 @@ private void LayoutSettingsService_PropertyChanged(object? sender, PropertyChang
162175 if ( e . PropertyName == nameof ( ILayoutSettingsService . ListViewSize ) )
163176 {
164177 NotifyPropertyChanged ( nameof ( RowHeightListView ) ) ;
178+ NotifyPropertyChanged ( nameof ( IconBoxSizeListView ) ) ;
165179
166180 // Update the container style to match the item size
167181 SetItemContainerStyle ( ) ;
168-
169- FolderSettings_IconHeightChanged ( ) ;
182+ FolderSettings_IconSizeChanged ( ) ;
170183 }
171184 if ( e . PropertyName == nameof ( ILayoutSettingsService . TilesViewSize ) )
172185 {
173186 NotifyPropertyChanged ( nameof ( ItemWidthTilesView ) ) ;
174187
175188 // Update the container style to match the item size
176189 SetItemContainerStyle ( ) ;
177- FolderSettings_IconHeightChanged ( ) ;
190+ FolderSettings_IconSizeChanged ( ) ;
178191 }
179192 if ( e . PropertyName == nameof ( ILayoutSettingsService . GridViewSize ) )
180193 {
181194 NotifyPropertyChanged ( nameof ( ItemWidthGridView ) ) ;
182195
183196 // Update the container style to match the item size
184197 SetItemContainerStyle ( ) ;
185-
186- FolderSettings_IconHeightChanged ( ) ;
198+ FolderSettings_IconSizeChanged ( ) ;
187199 }
188200
189201 // Restore correct scroll position
190202 ContentScroller ? . ChangeView ( previousHorizontalOffset , previousVerticalOffset , null ) ;
191203 }
192204
193- private async void FolderSettings_LayoutModeChangeRequested ( object ? sender , LayoutModeEventArgs e )
205+ private void FolderSettings_LayoutModeChangeRequested ( object ? sender , LayoutModeEventArgs e )
194206 {
195207 if ( FolderSettings . LayoutMode == FolderLayoutModes . ListView
196208 || FolderSettings . LayoutMode == FolderLayoutModes . TilesView
@@ -199,13 +211,7 @@ private async void FolderSettings_LayoutModeChangeRequested(object? sender, Layo
199211 // Set ItemTemplate
200212 SetItemTemplate ( ) ;
201213 SetItemContainerStyle ( ) ;
202-
203- var requestedIconSize = FolderSettings . GetRoundedIconSize ( ) ;
204- if ( requestedIconSize != currentIconSize )
205- {
206- currentIconSize = requestedIconSize ;
207- await ReloadItemIconsAsync ( ) ;
208- }
214+ FolderSettings_IconSizeChanged ( ) ;
209215 }
210216 }
211217
@@ -487,17 +493,14 @@ protected override async void FileList_PreviewKeyDown(object sender, KeyRoutedEv
487493 protected override bool CanGetItemFromElement ( object element )
488494 => element is GridViewItem ;
489495
490- private async void FolderSettings_IconHeightChanged ( )
496+ private void FolderSettings_IconSizeChanged ( )
491497 {
492- // Get new icon size
493- var requestedIconSize = FolderSettings . GetRoundedIconSize ( ) ;
494-
495- // Prevents reloading icons when the icon size hasn't changed
496- if ( requestedIconSize != currentIconSize )
498+ // Check if icons need to be reloaded
499+ var newIconSize = LayoutSizeKindHelper . GetIconSize ( FolderSettings . LayoutMode ) ;
500+ if ( newIconSize != currentIconSize )
497501 {
498- // Update icon size before refreshing
499- currentIconSize = requestedIconSize ;
500- await ReloadItemIconsAsync ( ) ;
502+ currentIconSize = newIconSize ;
503+ _ = ReloadItemIconsAsync ( ) ;
501504 }
502505 }
503506
0 commit comments