How to request a permission from a different view?

女生的网名这么多〃 提交于 2019-12-12 03:09:09

问题


I have a Project which contains three views: A MainView, which contains the two other views. The two sub-views contain Lists of Objects (Let's call them View A and B), which are largely independent. But sometimes there is a connection between the objects, which are contained in the Lists. Since the dawn of time, only Objects from List A "knew" about objects of Type B, Type B has no Idea that A could exist. This was intended behaviour and would be difficult to change. But know I have a Problem: Objects from List B can be deleted, but that is not a good idea when it is referenced by an Object of Type A. Would I would like to do is to somehow "ask" View A, if some of its objects are having a connection to the Object to be deleted. If so, I would inform the user. But how can I model that? The Views A and B don't know each other. Going through the MainView would be "wrong". I would use an event, but If I understand Caliburn correctly, I can only send an event, but cannot recieve feedback. Any Ideas?


回答1:


EventAggregator looks like a solution.

  1. Your user select an object and clicks delete.
  2. your click handler in View B sends a message1 with id (or whatever you use to identify) of object to delete.
  3. View A receives the message1 and sends a message2 with the result of the check (delete/ don't delete)
  4. View B receives the message2 and deletes the object or warns the User.

message1 and message2 are completely independent, different types.



来源:https://stackoverflow.com/questions/20374478/how-to-request-a-permission-from-a-different-view

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!