Refactor Application Settings and Support for Packaged/Unpackaged Mode #1924
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);
}
Looks like there’s an issue when running the app unpackaged:
- Navigate to
App notificationpage- Click
Show notificationbuttonThe 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
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.
/azp run