本文介绍了您将如何在mvvm中设计与Viewmodel的业务逻辑交互的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 视图模型可以获得业务逻辑的方式有哪些。可以说,我有3个模型,基于这3个模型数据,我将生成(基本上计算)一些新值(比如模型4),我将在View中显示这个模型4数据。 注意我不能将计算逻辑放在服务端,因为我没有控制权。我必须在我身边计算模型4.我应该在哪里计算这个模型4值? 问题1)调用服务表单ViewModel即GetModel_1_Data,GetModel_2_Data,GetModel_3_Data是不是很好的做法? 2)根据mvvm,我不允许在ViewModel上拥有业务逻辑......那我该怎么办?我们有什么不同的方式来实现这个目标? 3)在Mvvm中,我看到UI消耗的模型基本上是使用INotifyProperty的模型..什么是正确的单词来调用它们...我可以称为UI模型吗?或UI模型对象?其他模型就像普通的CLR对象一样。 当我读到关于mvvm的许多人说要保持Model..whic模型中的逻辑..他们的意思是普通的clr类......或者UI模型(他们有INotifyPropertyChanged)如果我们不需要有一些层来从POCO模型生成UI模型吗?这层被称为 ..如此...... 谢谢你, 解决方案What are the ways where a viewmodel can get business logic. Lets say, I have 3 Models and based those 3 models data I will produce(basically calculation) some new values(lets say model 4) where I will show this Model 4 data in View.Note I can not put calculation logic on service side because i dont have control..on them. I have to compute Model 4 on my side.. Where should I compute this Model 4 Values?Questions 1) Is it good practice to call Service form ViewModel i.e GetModel_1_Data,GetModel_2_Data, GetModel_3_Data if not whats the good practice ?2) As per mvvm I am not allowed to have business logic on ViewModel ...then where should I do? What are different ways we can achieve..this ?3) In Mvvm I see models consumed by UI basically Models with INotifyPropertychanged .. what is the right word to call them.. can I call as UI Models? or UI model objects? Other Models just like plain CLR objects.when I read about mvvm many say to keep logic in Model..whic model ..does they mean plain clr classes..or UI models(where they have INotifyPropertyChanged) If not do we need to have some layer to produce UI Models from POCO models? What this layer is called ..if so...Thankyou, 解决方案 这篇关于您将如何在mvvm中设计与Viewmodel的业务逻辑交互的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-04 08:52