Tell me how to serialize the created Item's in the panel, their text, the CheckBox value and the Delete button, and desserialize when the program is restarted? I understand how to do this with simple text or a class, but I have no idea what to do with the whole User Control ... enter image description here

  • Choose a suitable format ( JSON (advise), XML ), create a certain model that will contain all the necessary fields and attach them to them (if WPF, then banal Binding). When changing or closing an application, serialize it in the desired format. And of course when opening an application, reverse deserialization from a file into a model. - EvgeniyZ

2 answers 2

You do not need to serialize the controls.

Serialization of data for that and serialization that we convert them to a format convenient for reading, sending and writing.

In the screenshot, I see that you are going to serialize your to-do list. What is the minimum necessary to submit one thing? Case description and status.

So write in JSON or a similar format array, one element of which looks like this:

 {description: "Meet with Sergey", status: false} 

And then you read your file, spawn the necessary number of checkboxes, shove them onto the panel and fill in according to the contents of the file.

  • How do I implement this in code? - DocTor
  • @DocTor Take a JSON library, create an array of structures / objects with the ToDo status and description fields, add the data from your checkboxes and serialize it. - Trashbox Bobylev
  • Thanks for the help, I will try to do - DocTor

To save state in .NET, you don’t need to reinvent the serialized bike. Just record your data in Settings, and the next time they start, they will be automatically restored. (See pictures here .)