Alex
Alex

Reputation: 2122

WPF listview, Load, Save & Add

I have a columned listview who's items I would like to store in an XML file.

What's the best way to go about loading, saving and adding items?

Upvotes: 1

Views: 469

Answers (1)

Bek Raupov
Bek Raupov

Reputation: 3777

best way is to use MVVM :), that way your View simply represents the data in the UI. Actual DomainModel/BusinessObject resides outside your View.

And then you can use number of persistance methods:

  • XML Serialization

  • ORM (Object Relation Mapping), which will persist/save the BusinessObject into Database and back

Step by step way:

  • Create/Define your BusinessObject(DomainModel, i.e. Person class)

  • Use DataTemplate to Bind to Collection from your ListView

  • In your ViewModel, you can than say PersonCollection.Save/Load etc

Upvotes: 1

Related Questions