MVVM with XML model and LinqToXml?

I read in the MVVM pattern and I would like to try it in a relatively small WPF project. The application will be single-user. Both input and output will be stored in a "relational" XML file. To check the file, a scheme (XSD file) with Keys and KeyRefs is used.

I also started to wet my feet with Linq and LinqToXml, and I wrote some pretty complicated queries that really work (small wins :)).

Now, I'm trying to put it all together, and I find that I'm a little confused about what should be in the Model compared to the ViewModel. Here are the options I've struggled with so far:

  • Should I consider the model of the XML file itself and put all the LinqToXml requests in the ViewModel? In other words, don't you even write a class called Model?
  • Should I write a model that is just a simple wrapper for an XML file and a set of XSD schemas and does validation, saves changes, etc.?
  • Should I put the "main" queries in the queries "Model" and "View specific" in the ViewModel? And if so, where should I draw the line between these two categories?

I understand that this is not necessarily the “right” answer to this question ... I'm just looking for tips and pros / cons, and if anyone knows an example code for such a scenario, that would be great.

Thanks,

Dan

+3
source share
2 answers

, , , , , . /, , , .

(.. XML, ) , .

- , , , ( , -).

, - (WPF, ), .

XML LINQ to XML .

MVVM, ViewModel , .

, , -, Domain, , , . . . ViewModel .

, WPF, ViewModel, WPF.

+3

, , , WPF, O'Reilly " WPF".

Windows Presentation Foundation
http://hanselminutes.com/default.aspx?showID=184

( ) , , .

. , .

0

Source: https://habr.com/ru/post/1712707/


All Articles