How to save the UI state of A WPF Application before closing?

MERUN KUMAR MAITY 511 Reputation points
2022-07-20T19:09:18.16+00:00

I have a WPF application where I use multiple controls like button, combo box, check box, Tree view etc. I use a lot of visual styles and control templates to look my application modern and stylist. My application works perfectly as much as I want but one problem is I want to save the UI state of my application because as soon as I close my application all the selected values like check box state, comb box selected value, tree view state etc will removed and if I started application again then I don't see any previous state and values which I done before. Most people recommended me to use the Application settings feature which is officially from Microsoft but I don't have any clear idea that how to use it?

By the way, My WPF application is a MVVM base where I use multiple view model to manipulate the UI layer with proper data abstraction. Does the saving approach of a UI state is slightly different for a MVVM base WPF application?

My main question is what is the efficient way to save the UI state of a MVVM base WPF application? either it is a simple application settings or it will be some kind of complex data binding?

I don't include any source code because it's nothing to do with my application source code because giving the full source code of my application is quite impossible also. Just create a demo WPF application include some check box and combo box give them value and save them before closing the application.

Our main goal is to find a simple way to save the UI state not any complex method. Another important point to remember is, my WPF application don't use any external database or any other web data services so, that I save the UI state over the internet and fetch it whenever I want to use at the time of starting my application.

All the saving process of the UI state of my WPF application should be done locally in the client machine on which the application is running.

Windows Presentation Foundation
Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,663 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,175 questions
{count} votes