Exrin: ViewModel vs VisualState vs Model vs ModelState clarification

走远了吗. 提交于 2019-12-08 03:28:02

问题


I've watched through the Exrin tutorial multiple times and have looked through the couple different samples online which are very helpful to getting started, but one thing I'm having a hard time understanding is the ViewModel vs VisualState vs Model vs ModelState approach Exrin uses and would like some clarification as to what types of properties/other items get stored in each and how they relate to each other.


回答1:


First, here is a diagram of how it is setup.

Second, going through an example. Say you have an API that gets a list of items.

You would do this.

  1. In your Model, create a method that calls the Service or API to get a list of items.
  2. In your ViewModel, in OnNavigated/ICommand, or whatever event you want to call it from, make a call to the Model to get this list of items.
  3. Store this list of items in a property in your VisualState
  4. In your View in XAML, {Binding VisualState.ListOfItems}


来源:https://stackoverflow.com/questions/44166088/exrin-viewmodel-vs-visualstate-vs-model-vs-modelstate-clarification

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!