开发者

wpf insert data from views using mvvm method

开发者 https://www.devze.com 2023-04-12 03:36 出处:网络
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 mod开发者_开发百科el when press save butt

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 mod开发者_开发百科el when press save button.


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消