How to request a permission from a different view?

2019-09-02 21:07发布

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条回答
做个烂人
2楼-- · 2019-09-02 21:24

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.

enter image description here

查看更多
登录 后发表回答