WinUI-Gallery icon indicating copy to clipboard operation
WinUI-Gallery copied to clipboard

Refactor Application Settings and Support for Packaged/Unpackaged Mode #1924

Open ghost1372 opened this issue 4 months ago • 3 comments

This PR replaces the legacy ApplicationData-based settings system with a new SettingsHelper class. It adds support for both packaged and unpackaged app scenarios.

Closes #1924.

Old Settings System:

appData.LocalSettings.Values[SettingsKeys.IsLeftMode] = true; New Settings System:

SettingsHelper.Current.IsLeftMode = true;

[!Note] Settings are automatically saved when changed.

SettingsHelper Architecture:

Uses an ISettingsProvider abstraction. In packaged mode: uses ApplicationDataContainer. In unpackaged mode: uses JsonSettingsProvider.

Adding a New Setting:

public bool IsEnabled
{
    get => GetOrCreateDefault<bool>(true);
    set => Set(value);
}

ghost1372 avatar Aug 07 '25 14:08 ghost1372

Looks like there’s an issue when running the app unpackaged:

  • Navigate to App notification page
  • Click Show notification button

The app crashes with an unhandled exception.

The AppNotificationManager throws an "Element Not Found" exception and is not related to this PR! This crash can be easily fixed but should be addressed in a separate PR.

As described here, we need to register it. I tested it, and it works fine in the unpackaged scenario. So, this requires additional work and should be done in a separate PR (we can keep the current logic for packaged mode and add a registration/scenario for unpackaged mode). Here are the Microsoft docs and samples for unpackaged scenarios. https://learn.microsoft.com/en-us/windows/apps/develop/notifications/app-notifications/app-notifications-quickstart?tabs=cs https://github.com/microsoft/WindowsAppSDK-Samples/tree/main/Samples/Notifications/App/CsUnpackagedAppNotifications/CsUnpackagedAppNotifications

ghost1372 avatar Sep 10 '25 12:09 ghost1372

Hi @marcelwgn Thank you for your review. I’ve addressed the suggestions you made earlier. I’ve added migration methods to preserve the user’s Favorites and Recently Visited items.

ghost1372 avatar Sep 28 '25 16:09 ghost1372

/azp run

marcelwgn avatar Nov 17 '25 11:11 marcelwgn