I encountered a problem while using CommunityToolkit 8.2 IRecipient, which includes IRecipient<Value ChangedMessage>and IRecipient<PropertyChangedMessage>. What are the roles of Value ChangedMessage and PropertyChangedMessage?
Only defining IRecipientas able to receive messages, adding ValueChangedMessage or PropertyChangedMessage will result in incorrect message reception.
I still haven’t figured it out, please help me interpret it. thanks!
public partial class TestViewModel: ObservableRecipient, IRecipient<PropertyChangedMessage<string>>
{
[ObservableProperty]
private string info = "message";
public TestViewModel()
{
IsActive = true;
}
public void Receive(PropertyChangedMessage<string> message)
{
Info = message.NewValue;
}
}
The above is the code I tested, but it is defined that IRecipientcan receive messages. Of course, after defining IRecipient, the Receive method will also change.
user24211519 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.