Repository: files-community/Files
File: src/Files.App/Views/Layouts/GridLayoutPage.xaml.cs (C#)

Code before:

				// Update the container style to match the item size
				SetItemContainerStyle();

				FolderSettings_IconHeightChanged();
			}

			// Restore correct scroll position
			ContentScroller?.ChangeView(previousHorizontalOffset, previousVerticalOffset, null);
		}

		private async void FolderSettings_LayoutModeChangeRequested(object? sender, LayoutModeEventArgs e)
		{
			if (FolderSettings.LayoutMode == FolderLayoutModes.ListView
				|| FolderSettings.LayoutMode == FolderLayoutModes.TilesView
				|| FolderSettings.LayoutMode == FolderLayoutModes.GridView)
			{
				// Set ItemTemplate
				SetItemTemplate();
				SetItemContainerStyle();

				var requestedIconSize = FolderSettings.GetRoundedIconSize();
				if (requestedIconSize != currentIconSize)
				{
					currentIconSize = requestedIconSize;
					_ = ReloadItemIconsAsync();
				}
			}
		}

		private void SetItemTemplate()
		{
			var newFileListStyle = FolderSettings.LayoutMode switch
			{
				FolderLayoutModes.ListView => (Style)Resources["VerticalLayoutGridView"],
				FolderLayoutModes.TilesView => (Style)Resources["HorizontalLayoutGridView"],
				_ => (Style)Resources["HorizontalLayoutGridView"]
			};

			if (FileList.Style != newFileListStyle)
			{
				var oldSource = FileList.ItemsSource;
				FileList.ItemsSource = null;
				FileList.Style = newFileListStyle;
				FileList.ItemsSource = oldSource;
			}

			shouldSetVerticalScrollMode = true;

			switch (FolderSettings.LayoutMode)
			{

Review comment (suggestion):
I don't think there is any advantage to not awaiting here because event handlers themselves run asynchronously.

Code after:
				FolderSettings_IconSizeChanged();
			}
			if (e.PropertyName == nameof(ILayoutSettingsService.TilesViewSize))
			{
				NotifyPropertyChanged(nameof(ItemWidthTilesView));

				// Update the container style to match the item size
				SetItemContainerStyle();
				FolderSettings_IconSizeChanged();
			}
			if (e.PropertyName == nameof(ILayoutSettingsService.GridViewSize))
			{
				NotifyPropertyChanged(nameof(ItemWidthGridView));

				// Update the container style to match the item size
				SetItemContainerStyle();
				FolderSettings_IconSizeChanged();
			}

			// Restore correct scroll position
			ContentScroller?.ChangeView(previousHorizontalOffset, previousVerticalOffset, null);
		}

		private void FolderSettings_LayoutModeChangeRequested(object? sender, LayoutModeEventArgs e)
		{
			if (FolderSettings.LayoutMode == FolderLayoutModes.ListView
				|| FolderSettings.LayoutMode == FolderLayoutModes.TilesView
				|| FolderSettings.LayoutMode == FolderLayoutModes.GridView)
			{
				// Set ItemTemplate
				SetItemTemplate();
				SetItemContainerStyle();
				FolderSettings_IconSizeChanged();
			}
		}

		private void SetItemTemplate()
		{
			var newFileListStyle = FolderSettings.LayoutMode switch
			{
				FolderLayoutModes.ListView => (Style)Resources["VerticalLayoutGridView"],
				FolderLayoutModes.TilesView => (Style)Resources["HorizontalLayoutGridView"],
				_ => (Style)Resources["HorizontalLayoutGridView"]
			};

			if (FileList.Style != newFileListStyle)
			{
				var oldSource = FileList.ItemsSource;
				FileList.ItemsSource = null;
				FileList.Style = newFileListStyle;
				FileList.ItemsSource = oldSource;