MVVM light - how to access property in other view model

前端 未结 3 564
情深已故
情深已故 2020-11-28 10:49

I\'m using mvvm light to build a Silverlight application. Is there a code snippet that shows how to access a view model\'s property or command from within another view model

3条回答
  •  温柔的废话
    2020-11-28 11:34

    Another way is to use the overload of RaisePropertyChanged that also broadcasts the change. You would do this:

    RaisePropertyChanged(() => MyProperty, oldValue, newValue, true);
    

    Then in the subscriber:

    Messenger.Default.Register>(this, Handler);
    

    where T is the type of MyProperty.

    Cheers Laurent

提交回复
热议问题