MVVM Light Messenger executing multiple times

后端 未结 5 1738
不知归路
不知归路 2021-01-13 11:29

I am using MVVM Light and am using Messages to communicate between ViewModels to let a ViewModel know when it is ok to execute something. My problem is that I register for

5条回答
  •  攒了一身酷
    2021-01-13 12:07

    Very old question but I solved the problem by doing this:

    static bool isRegistered = false;

    and then, in the constructor:

    if( !isRegistered )
    {
       Messenger.Default.Register(this, OnMessageReceived);
       isRegisterd = true;
    }
    

提交回复
热议问题