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

UnPackaged Mode is Broken

Open ghost1372 opened this issue 5 months ago • 3 comments

Which version of the app?

WinUI 3 Gallery

Description

Unpackaged mode is broken due to the use of LocalSettings for saving app settings, which is not supported in unpackaged apps.

I’m considering two possible solutions:

  1. Implement a simple class to serialize/deserialize a model to a JSON file — straightforward, with no extra features.

  2. Use Nucs.JsonSettings, which offers features like:

    • Versioning
    • AutoSave
    • And more...

I’m ready to submit a PR.

Screenshots

No response

Windows version

No response

Additional context

No response

ghost1372 avatar Jul 19 '25 09:07 ghost1372

@marcelwgn

Could you pick one option so I can begin?
If I implement a custom Serializer class, it’ll be a simple setup—something like

GlobalData.Settings.Property = true;
GlobalData.Save();

However, saving and restoring collections might be a bit tricky.
On the other hand, using nucs.JsonSettings would be much easier and comes with plenty of useful features. For example, you can use

Settings.Property = true;

and it saves automatically. Plus, two-way x:Bind support could be really powerful. nucs.JsonSettings is open-source and licensed under the MIT license, so I don't think there's any issue with using it.

ghost1372 avatar Jul 21 '25 15:07 ghost1372

I think we should implement a simple serializer ourselves, pulling in dependencies, especially as a reference project like the WinUI Gallery is has its own suite of problems. We should probably just use a JSON Serializer for this instead of trying to be too smart here. The API surface should be similar to the existing AppSettings and that switch should be implemented in the SettingsHelper class.

marcelwgn avatar Jul 24 '25 06:07 marcelwgn

Hi @marcelwgn I added a PR for this issue https://github.com/microsoft/WinUI-Gallery/pull/2001

Old Settings System:

appData.LocalSettings.Values[SettingsKeys.IsLeftMode] = true;

New Settings System:

SettingsHelper.Config.IsLeftMode = true;
SettingsHelper.Save();
Image

ghost1372 avatar Jul 30 '25 16:07 ghost1372