1

I have an application that defines two modules, let's ModuleA and ModuleB for simplicity. Each one has it's own ViewModel, (for instance, ViewModelA, ViewModelB). When the first module (ModuleA) is loaded, ViewModelA is instantiated displaying data into ViewA (the default and only view in that module). Same for ModuleB. Each View is loaded through RequestNavigation, clicking in buttons defined in the shell, inside a RibbonView. So, Button A calls

regionManager.RequestNavigate(regionName: "ContentRegion", source: uri, navigationCallback: NavigationCompleted);

With URI parameter like:

uri = new Uri(uriString: typeof(ViewA).FullName, uriKind: UriKind.Relative);

The app is working, but the problem is this: the data displayed by ViewModelA modifies through a service class the data displayed by ViewModelB. So, when I modify data in ViewA and then I navigate to ViewB the data is still the same, forcing me to reload the entire app to see changes in ViewB. So, how can I force reloading on ViewModelB (reinstantiating or something) so each time I modify the data ViewModelA provides in ViewA the changes will be visible in ViewB?

As of now, ViewModelA and ViewModelB are populated only once, and this occurs when I register the modules in bootstrapper.

Thanx in advance.

Gonza Romero
  • 81
  • 2
  • 6
  • Do the properties in each view model publish their changes to observers? – Neil Dec 12 '17 at 21:36
  • @Neil absolutely. Everythin's working as expected, except this. I'm running now every Prism 6 code example to better understand what I'm doing wrong, but as far as I know, everything's ok at my side. So, right now it's a matter of guessing. I'm still clueless. Thanks for your response anyway. – Gonza Romero Dec 13 '17 at 11:40
  • If you have 2 independent view models, and the service modifies the data in only one of the view models, then as they aren't directly linked, you won't get an update in the other view model. I think it's time you created a small working example of the problem (admittedly, it being MVVM, it will be more than a few lines). – Neil Dec 13 '17 at 12:32
  • @Neil I think you're right. I'll code a proof-of-concept example and Im going to upload it to a box.net account in the next two hours. By the way, two minutes ago I discovered that if I navigate between ViewA and ViewB each time the corresponding ViewModel gets instantiated and data populated...but if in ViewA you execute the command (DelegateCommand defined of course in ViewModelA) that creates data related to ViewModelB, when you navigate from ViewA to ViewB to actually see the ViewB data updated (from ViewModelB) ViewModelB doesn't get instantiated AT ALL, showing the same old original data – Gonza Romero Dec 13 '17 at 12:45

0 Answers0