joms
joms

Reputation: 51

wpf insert data from views using mvvm method

I am new in wpf .i want to know how to insert data from views to XML using mvvm method. i am using xml as database.actually i want to know how data go to view model when press save button.

Upvotes: 0

Views: 430

Answers (2)

Vinit Sankhe
Vinit Sankhe

Reputation: 19885

Your best bet is to use XmlDocument type to load the Xml data and then bind it to DataGrid's ItemsSource property. Create columns based on xmlNode.Attributes.

Upvotes: 2

Haris Hasan
Haris Hasan

Reputation: 30097

In MVVM your current/present data always exist in ViewModel, so there is no need to pass data to View Model in order to save it. Your View always shows/display data that exist in ViewModel. So on Save button click you should just save data in to XML which already exist in ViewModel most probably contained in some collection or other similar data structure.

Upvotes: 1

Related Questions