【发布时间】:2013-03-14 01:18:43
【问题描述】:
是否可以在 MVVM Light Message 中发送列表。
例如,我有一个名为 Authors 的类。我要发送
Messenger.Default.Send(AuthorList); // AuthorList is of type List<Author>
在我正在写的视图模型的构造函数中
Messenger.Default.Register<List<Author>>(this, authList =>
{MessageBox.Show(authList[0].name)});
我已确保在发送消息之前调用了构造函数。但这似乎不起作用。
【问题讨论】:
-
您是否收到错误消息?我认为您需要明确说明要发送的类型。
Messenger.Default.Send<List<Author>>(AuthorList); -
我试过明确说明发送类型。这没有帮助。
-
你能否毫无问题地将其他(非列表)消息发送到同一个 ViewModel?
标签: wpf mvvm mvvm-light