Skip to content

Conversation

@0x5bfa
Copy link
Member

@0x5bfa 0x5bfa commented Nov 14, 2025

Vision towards NativeAOT in the Sidebar functionalities

The current Quick Access helper and its watcher is powered by the reflection-based Activator to instantiate the Quick Access's IShellFolder to enumerate Quick Access items instead of Win32 CoCreateInstance due to UWP limitations. This is now blocking us from leveraging NAOT for faster startup and Trimming for a smaller package size.

I have already refactored the codebase of the Home page, which is relatively ready for the next Storage Abstraction concept. However, that of the Sidebar controls is not yet at all, which is overly complicated and requires to a major refactoring for the NAOT/Trimming adoption.

The first example of the complication is the specifically implemented receivers of events that come from Quick Access, Drives, etc.

public async Task UpdateSectionVisibilityAsync(SectionType sectionType, bool show)
{
if (show)
{
var generalSettingsService = UserSettingsService.GeneralSettingsService;
Func<Task> action = sectionType switch
{
SectionType.CloudDrives when generalSettingsService.ShowCloudDrivesSection => CloudDrivesManager.UpdateDrivesAsync,
SectionType.Drives => drivesViewModel.UpdateDrivesAsync,
SectionType.Network when generalSettingsService.ShowNetworkSection => NetworkService.UpdateComputersAsync,
SectionType.WSL when generalSettingsService.ShowWslSection => WSLDistroManager.UpdateDrivesAsync,
SectionType.FileTag when generalSettingsService.ShowFileTagsSection => App.FileTagsManager.UpdateFileTagsAsync,
SectionType.Library => App.LibraryManager.UpdateLibrariesAsync,
SectionType.Pinned => App.QuickAccessManager.Model.AddAllItemsToSidebarAsync,
_ => () => Task.CompletedTask
};
Manager_DataChanged(sectionType, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
await action();
}
else
{
sidebarItems.Remove(sidebarItems.FirstOrDefault(x => x.Section == sectionType));
}
}

Secondly, the decoupled control SidebarView takes a view model for it. We should be passing references to DPs controlled in the MainPageViewModel instead of having a dedicated view model for this control.

<controls:SidebarView
x:Name="SidebarControl"
Grid.Row="2"
HorizontalAlignment="Stretch"
HorizontalContentAlignment="Stretch"
DisplayMode="{x:Bind SidebarAdaptiveViewModel.SidebarDisplayMode, Mode=TwoWay}"
IsPaneOpen="{x:Bind ViewModel.IsSidebarPaneOpen, Mode=TwoWay}"
Loaded="SidebarControl_Loaded"
MenuItemsSource="{x:Bind SidebarAdaptiveViewModel.SidebarItems, Mode=OneWay}"
OpenPaneLength="{x:Bind UserSettingsService.AppearanceSettingsService.SidebarWidth, Mode=TwoWay}"
SelectedItem="{x:Bind SidebarAdaptiveViewModel.SidebarSelectedItem, Mode=TwoWay}"
ViewModel="{x:Bind SidebarAdaptiveViewModel}">

Thirdly, SidebarView is a UserControl instead of a control that derives from Control, so-called being a custom control. As aforementioned, since the control depends on an instance of a dedicated view model, there's a strong bond between this control and the view model. We should make use of events instead and isolate the control from the implementation details of the view model.

public sealed partial class SidebarView : UserControl, INotifyPropertyChanged


With these reasons, we should be going to refactor the sidebar implementations to get rid of the view model reference and to implement better bindings of sidebar items collection. This PR is the first one of the series of improvements, the next one would refactor the sidebar item models and probably replace the view model.

Resolved / Related Issues

Steps used to test these changes

Since this has no functionality change, this PR can be validated by just deploying and running the app.

  1. Open Files app

@0x5bfa 0x5bfa force-pushed the 5bfa/CQ-QuickAccess branch from dd8a033 to d5ef98f Compare November 14, 2025 17:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant