Exrin:ViewModel与VisualState,Model与ModelState的说明 [英] Exrin: ViewModel vs VisualState vs Model vs ModelState clarification
问题描述
我已经多次阅读 Exrin教程,并且已经看过通过夫妇 样品在线这对入门非常有帮助,但是我很难理解的一件事是Exrin使用的ViewModel vs VisualState vs Model vs ModelState方法,并希望对每种类型中存储的属性/其他项目的类型进行一些说明.它们如何相互联系.
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.
推荐答案
首先,下面是它的设置方法图.
First, here is a diagram of how it is setup.
第二,通过一个例子.假设您有一个获取项目列表的API.
Second, going through an example. Say you have an API that gets a list of items.
您会这样做.
- 在模型中,创建一个调用服务或API的方法以获取项目列表.
- 在ViewModel中,在OnNavigated/ICommand中,或者您想从中调用它的任何事件中,调用Model以获得此项目列表.
- 将此项目列表存储在VisualState的属性中
- 在XAML中的视图中,
{Binding VisualState.ListOfItems}
- In your Model, create a method that calls the Service or API to get a list of items.
- 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.
- Store this list of items in a property in your VisualState
- In your View in XAML,
{Binding VisualState.ListOfItems}
这篇关于Exrin:ViewModel与VisualState,Model与ModelState的说明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!