Yes, it is possible to automatically store and load WPF settings from a finished settings page using C#.
The most common way to do this is to use the Settings class in .NET. The Settings class allows you to store key-value pairs of settings in an XML file, which can be loaded and saved at runtime.
Here is an example of how you can use the Settings class to store and load settings in a WPF application:
using System.Configuration;
// Save a setting
Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingSettings);
config.AppSettings.Settings["MySetting"].Value = "Some Value";
config.Save();
// Load a setting
config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingSettings);
string value = config.AppSettings.Settings["MySetting"].Value;
To store specific controls with a flag, you can use the Settings class in conjunction with a custom class that inherits from DependencyObject and implements the ISupportInitialize interface. This will allow you to save and load the state of the controls when the custom class is initialized.
Here is an example of how you can use the Settings class and a custom class to store and load the state of a TextBox control:
using System.Configuration;
using System.Windows;
// Save a setting
TextBox textBox = new TextBox();
textBox.Text = "Some Text";
textBox.Name = "MyTextBox";
Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingSettings);
config.AppSettings.Settings["MyTextBox"].Value = textBox.ToString();
config.Save();
// Load a setting
config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingSettings);
object value = config.AppSettings.Settings["MyTextBox"].Value;
TextBox textBox = (TextBox)Activator.CreateInstance(typeof(TextBox), value);
I hope this helps! Let me know if you have any questions.