在mvvm部署中部署弹出窗口 [英] Deployment of a popup window in an mvvm deployment

查看:70
本文介绍了在mvvm部署中部署弹出窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在使用一个古老的ASP应用程序,并使用MVVM设计模式将其移至Silverlight.我们将Prism和Unity用于MVVM框架.我们不使用MEF.

我们有一种可以处理多个表的表格,我已经解决了大多数(如果不是全部)问题.一个有问题的应用程序是唯一脱离"notes"应用程序并以其自己的形式处理的应用程序.我们希望有一个添加评论"按钮,该按钮将显示一个弹出窗口,收集数据,然后在完成后更新评论表.

处理弹出过程的最佳实践是什么?我是否应该使CanShow在其自身上具有支持它的自己的视图模型的视图? (我正在考虑的方法)

看来,如果我在Unity中保留它的实例,让事件获取对象并显示它,将它的创建绑定到视图模型,并与我们正在使用的贷方进行注入处理,它应该使一切保持静止当我们处理Notes应用程序时,它也非常独立,同时也使它可用.

这是最好的方法,还是有一种更好/更简单的方法而不将弹出窗口绑定到数据.

We are taking an ancient ASP application and moving it to Silverlight using the MVVM design pattern. We are using Prism and Unity for the MVVM framework. We are not using MEF.

We have one form that works with multiple tables and I have most (if not all) addressed. The one in issue is the only application that breaks away from the ''notes'' application and handles it in their own form. We want to have an ''Add Comment'' button which will expose a popup, gather the data, then update the comment table when done.

What is the best practise for handling the popup process? Should I make it a view that CanShow on it''s own with it''s own viewmodel supporting it? (the approach I''m thinking of)

It seems if I keep an instance of it in Unity, have the event get the object and show it, have the creation of it bind to the view model, and have injection deal with the lender we are working with, it should keep things still quite separated while also making this usable when we address the Notes application as well.

Is this the best approach or is there a better / simpler approach without binding the popup to the data.

推荐答案

万一有人在想.... my方法看起来效果很好.

我在Unity中定义了弹出窗口作为参考.
我也有在Unity中定义的视图模型.

我使用unity创建视图的实例,并通过Prism实例化了它自己的视图模型.
然后,我注册一个对CommentCreationComplete事件的订阅,并使用该事件来关闭窗口并重新获取视图模型中的数据.

仅绑定到Add Comment事件和在视图模型中调用方法时,工作就非常顺利.
In case anyone is wondering....my approach does seem to work quite well.

I have the popup defined in Unity as a Reference.
I have the view model defined in Unity as well.

I use unity to create an instance of the view and it has it''s own view model instantiated via Prism.
I then register a subscribe to the CommentCreationComplete event and use that to close the window and re-get the data in the view model.

Works quite smoothly with binding only to the event of Add Comment and that calling a method in the view model.


这篇关于在mvvm部署中部署弹出窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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