Click here to Skip to main content
15,883,705 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:
XML
<TextBox x:Uid="Settings_Smtp_ServerBox" Text="{x:Bind ViewModel.SmtpServer}" />


Inside the ViewModel i have some properties defined, where the textboxes bound to:
C#
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:
C#
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/setting-storage.md at main · microsoft/TemplateStudio · GitHub[^]
but the saving process isn't documented.
Posted
Comments
[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