I am using WPF Prism for our development and we want to pass values from one view/view model to another view/view model and we can use either EventAggregator or UriQuery, so need suggestion which one to use.

Right now we can think of passing simple parameter like IDs.May be later on we have to pass objects but I know I cant directly pass object to uri query but we can manage it but passing fields.

I know how to implement these but wanted to know which one is preferable way or standard in Prism and MVVM.

Please suggest

有帮助吗?

解决方案

It is largely down to taste as both methods work.

I reserve UriQuery for navigation that involves a payload. This is the case in which UriQuery is discussed in the prism documentation. I don't like them because they use weakly typed data - in this case strings. You have to serialise and deserialise. For complex data, this is error prone.

An aggregated event lets you pass a Argument object when you publish the event. You do not have to serialise and deserialise the query but you will need a common library to define the argument class.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top