Replies: 2 comments
-
Any response here? AFAIK, As far as the AFAIK, senders to not need to register, can simply just do it, and the recipients do in fact receive and can respond via the message instance. i.e. var response = Messenger.Send<SomeMessage>(new());
// do something with response |
Beta Was this translation helpful? Give feedback.
-
Extending this idea, modern patterns, however, I need further guidance on how to leverage CT.Mvvm in view of the WPF XAML design mode. I am finding that, probably, involving Open to suggestions. |
Beta Was this translation helpful? Give feedback.
-
(Sorry, I had a better, complete text written on the GitHub mobile app, but I opened a GitHub link in the app and lost all the contents of my text in progress)
I'd like some help on how to use the messenger features of the toolkit, since I have difficulty understanding with the available resources. There are a lot of useful features and patterns in the toolkit with v8, and really like using them for the observable properties and all (I've been following and using before the official v8 release, since that was the only active MVVM toolkit when my project started).
However, what is the expected usage, in the context of the v8.x of the community toolkit for Messenger in MVVM, in a WPF app? I would want something that I can understand the pattern, like a complete file (or files) to see how to organize the usage, instead of only a paragraph.
The docs available on https://learn.microsoft.com/en-us/dotnet/communitytoolkit/mvvm/messenger were not updated that much with the new release, and frankly, were written for the v7.x release, where everything had to be done manually. The two other references are the MVVM-Samples repo and the unit tests. For the samples repo, the samples weren't really updated and maintained, and don't include the preferred usage nowadays, and is (was) more or less stale. I'm able to understand, even if it's not explicitly for WPF. For the unit tests, it's quite difficult to understand the "real world" usage in that dense code, that is really for another usage, tests.
I've looked multiple times in the last months through old issues and discussions, but either they are left unanswered, or do not contain enough code to understand the patterns.
I once managed to get a simple case of WeakReferenceMessenger working, but can't really understand it when rereading now, especially since they are different from the rest of the application, I had to write the properties manually in the long form, for both the sender and receiving side, i.e., like when it was the older v7.x, since that's what is documented.
So, how does messaging work between view models? When we write a viewmodel (class), we add the
: ObservableRecipient
, but if we add a type to this: ObservableRecipient<T>
, does it work directly? Do we send only a property or the whole object? I think I need to understand in order to choose how to make at least two ViewModels communicate some info. The contents of the tabs in my WPF app are independent usercontrols, these ViewModel contain the information, but it's time to have them share when an item was selected in a tab as a filter for another one.Beta Was this translation helpful? Give feedback.
All reactions