RaisePropertyChanged(字符串属性名称,T oldValue,T newValue,bool 广播)

发布于 2024-09-08 16:35:26 字数 448 浏览 1 评论 0原文

我试图让 RaisePropertyChanged(string propertyName, T oldValue, T newValue, bool Broadcast) 正常工作,但无法正常工作。

我并没有在任何现实场景中实现它,只是为了学习它。如果我以通常的方式进行广播,那么它就会起作用 Messenger.Default.Send(new PropertyUpdateeMessage("test"));

所以我想知道我缺少什么使用 RaisePropertyChanged(string propertyName, T oldValue, T newValue,bool 广播)

提前致谢。

问候 拉吉

I was trying to get the RaisePropertyChanged<T>(string propertyName, T oldValue, T newValue, bool broadcast) working but could not get it to work.

I am not implementing it in any real world scenario but just for learning it. If I raise broadcast the usual way only then it works
Messenger.Default.Send<PropertyUpdateeMessage>(new PropertyUpdateeMessage("test"));

So i am wondering what am i missing to use RaisePropertyChanged<T>(string propertyName, T oldValue, T newValue, bool broadcast)

Thanks in advance.

Regards
Raki

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

灯下孤影 2024-09-15 16:35:26

这也花了我一些时间才弄清楚。基本上,您必须将您正在注册的消息与您正在发送的消息进行协调,但关于它的文档并不多。

我有一个完整的工作示例此处,但以下是简而言之:

首先,注册 PropertyChangedMessage,指定总线上正在发生的类型

Messenger.Default.Register<PropertyChangedMessage<ObjectICareAbout>>(
    this,
    (action) => DispatcherHelper.CheckBeginInvokeOnUI(
                 () => DoWorkOnObject(action.NewValue) 
                )
);

然后在主 VM 的属性更改时发送消息

RaisePropertyChanged(SelectedItemPropertyName, oldValue, value, true);

在发送消息并注册以收听消息时,您可以使用一些消歧选项,但这就​​是方法基础工作有效。

This took me a bit to figure out too. Basically you have to coordinate the message you're registering with the message you're sending, but there isn't a lot of documentation about it.

I have a full working sample here, but here's the info in a nutshell:

First, register for the PropertyChangedMessage specifying the type that's going on the bus

Messenger.Default.Register<PropertyChangedMessage<ObjectICareAbout>>(
    this,
    (action) => DispatcherHelper.CheckBeginInvokeOnUI(
                 () => DoWorkOnObject(action.NewValue) 
                )
);

Then send the message out when the main VM's property changes

RaisePropertyChanged(SelectedItemPropertyName, oldValue, value, true);

There are some disambiguation options you can use when sending out the message and registering to hear it, but this is how the basics work.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文