c# - Returning Data to Previous a ViewModel using Prism Navigation -


imagine have 2 views, viewmodel infoviewmodel displays information person , viewmodel searchviewmodel handles searching person , selecting result.

i want infoviewmodel able initiate search process result in searchviewmodel telling view infoviewmodel has been selected. potential requirement infoviewmodel can communicate searchviewmodel result unacceptable , user should pick else (this should happen without search result screen disappearing , reappearing)

normally easy solve infoviewmodel giving searchviewmodel callback called whenever result selected. callback having return parameter specifying whether result or not searchviewmodel can clean or not. seems prism discourages since, @ least in prism 4.0, there no way navigate object parameter (you pass strings parameters). 1 of workarounds i'm using use service store object parameters can uniquely identified in next view way of string guid. has it's own problems, worse feels prism intentionally designed against doing this.

another way seems using ieventaggregator broadcast event when person selected. have filter each event based on unique id make sure event received me (in case reason there 2 search processes going on). feels way trying emulate direct callback in roundabout way.

does know of solution this? if answer there no way in prism 4.0 solve this, have on prism 5.0 (since supports passing object parameters) that's fine too. i'm wondering other ideas out there

there isn't 1 "right" answer, there different approaches.

you can navigate view passing details using navigationparameters class in prism5. if limited prism4, place parameters in regioncontext , access them in onnavigatedto method of the inavigationaware interface.

with regards "returning" results, might depend on layout of application. if multiple views allowed, registering , using event through event broker recommended way communicate between different components. if have 1 view , feel event broker unnecessary , perhaps overkill, consider using service paired searchviewmodel store results (not dissimilar appear doing already). other viewmodel can injected service, able access property details searchviewmodel has set.

if searching limited logically within parent view, consider using interactionrequest popup search view.


Comments

Popular posts from this blog

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -

javascript - Wordpress slider, not displayed 100% width -