Click here to Skip to main content
15,882,209 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Currently i'm experimenting with a WinUI3 project from the TemplateStudio and its the first time with MVVM.

I have some textboxes:
<TextBox x:Uid="Settings_Smtp_ServerBox" Text="{x:Bind ViewModel.SmtpServer}" />

Inside the ViewModel i have some properties defined, where the textboxes bound to:
public string SmtpServer
		get => _smtp_server;
		set => SetProperty(ref _smtp_server, value);

The mentioned project has a delivered local settings service what provides that method:
public class LocalSettingsServicePackaged : ILocalSettingsService
    public async Task SaveSettingAsync<T>(string key, T value)
        ApplicationData.Current.LocalSettings.Values[key] = await Json.StringifyAsync(value);

How do i save the contents of the properties?

What I have tried:

I read the documentation on TemplateStudio/ at main · microsoft/TemplateStudio · GitHub[^]
but the saving process isn't documented.
[no name] 2-Jul-22 12:52pm    
If designed properly, you would serialize / deserialize the view model (class). Serializing individual properties still implies a "settings class" simply for the sake of efficiency and sanity.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900