The default way of solving it is to use settings files. The problem with settings files is that you have to define all the settings and write the code that copies data back and forth yourself. Quite tedious if you have a lot of properties to keep track of.
I made a pretty flexible and very easy to use library for this, you just tell it which properties of which object to track and it does the rest. You can configure the crap out of it too if you like.
The library is called Jot (github), here is an old CodeProject article I wrote about it.
Here's how you'd use it to keep track of a window's size and location:
public MainWindow()
{
InitializeComponent();
_stateTracker.Configure(this)
.IdentifyAs("MyMainWindow")
.AddProperties(nameof(Height), nameof(Width), nameof(Left), nameof(Top), nameof(WindowState))
.RegisterPersistTrigger(nameof(Closed))
.Apply();
}
Jot vs. settings files: With Jot there's considerably less code, and it's a lot less error prone since you only need to mention each property once.
With settings files you need to mention each property 5 times: once when you explicitly create the property and an additional four times in the code that copies the values back and forth.
Storage, serialization etc are completely configurable. Also, when using IOC, you can even hook it up so that it applies tracking automatically to all objects it resolves so that all you need to do to make a property persistent is slap a [Trackable] attribute on it.
I'm writing all this because I think the library is top notch and I want to mouth off about it.