MVP模型中的通话视图 [英] Call View in MVP model

查看:83
本文介绍了MVP模型中的通话视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我是CAB编程和MVP模式的新手.
我知道主要的想法.

我的问:
我正在为我的CAB应用程序编写用户管理系统.
我有带userDataGrid和3个按钮(AddUser,ModUser,DelUser)的主视图(UserListView)
第二个视图(UserEditView)具有用户详细信息等.我们可以在此视图中保存新用户或更新现有用户数据.

当我单击第一个按钮时,我想要一个空白表格(UserEditView)
当我单击第二个按钮时,我希望具有已加载用户数据的表单已准备好进行编辑.

现在,如何根据UserListView中的按钮单击(第二个或第二个)调用第二个视图(UserEditView)?如何将参数或对象(用户)传递给View?

感谢您的答复.
抱歉,我的英语不好:(

Hi
I''m new in CAB programming and MVP patterns.
I know the main idea.

My Q:
I''m writing user managment system for my CAB-application.
I have main View (UserListView) with userDataGrid and 3 Buttons (AddUser, ModUser, DelUser)
The second View (UserEditView) has user details etc.. And we can save new user or update existing user data in this view.

When I click first button I want have a blank form (UserEditView)
When I click second button I want have form with loaded user data ready to be edited.

Now, how to call the seccond View (UserEditView) depending on button click in UserListView (first or second)? How to pass param or object(user) to View?

Thanks for reply.
Sory for my poor english :(

推荐答案

karol.pawelski写道:
karol.pawelski wrote:

如何将参数或对象(用户)传递给View

How to pass param or object(user) to View



它是通过接口完成的.

有关示例,请参见此处 [



It is done through interfaces.

For a sample, see here[^].


您可以向ViewModel添加"UserId"属性,如果该属性为null,则该用户是新用户,并且将显示空白表格;如果该属性具有值,则需要加载正确的用户并以该表格显示数据.
You could add a "UserId" property to the ViewModel, if the property is null then the user is new and you’ll show a blank form, if the property has a value then you need to load the correct user and show the data in the form.


这篇关于MVP模型中的通话视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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