❔ How do i handle user settings in wpf .net core
How do i handle user settings in WPF .NET 6?
System.Configuration?TestSettings instance (added and fetched from the Configuration object made by ConfigurationManager.OpenExeConfiguration) set as its datacontext and bound it there. Works fine setting values, changing values, restarting the program etc./close System.ConfigurationTestSettingsConfigurationConfigurationManager.OpenExeConfiguration<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="TestSettings" type="WpfApp1.TestSettings, WpfApp1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
</configSections>
<TestSettings OptIn="HellYes" />
</configuration>public class TestSettings : ConfigurationSection
{
public const string SectionName = nameof(TestSettings);
[ConfigurationProperty(nameof(OptIn), DefaultValue = CoolEnum.Unknown)]
public CoolEnum OptIn
{
get => (CoolEnum)this[nameof(OptIn)];
set => this[nameof(OptIn)] = value;
}
}
public enum CoolEnum
{
Unknown,
HellYes,
PleaseNo
}