Exrin:ViewModel与VisualState,Model与ModelState的说明 [英] Exrin: ViewModel vs VisualState vs Model vs ModelState clarification

查看:94
本文介绍了Exrin:ViewModel与VisualState,Model与ModelState的说明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经多次阅读 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.

您会这样做.

  1. 在模型中,创建一个调用服务或API的方法以获取项目列表.
  2. 在ViewModel中,在OnNavigated/ICommand中,或者您想从中调用它的任何事件中,调用Model以获得此项目列表.
  3. 将此项目列表存储在VisualState的属性中
  4. 在XAML中的视图中,{Binding VisualState.ListOfItems}
  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}

这篇关于Exrin:ViewModel与VisualState,Model与ModelState的说明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆