Xamarin Forms - Update multiple views/pages when one property changes

568 views Asked by At

I created a Xamarin forms application based on the tabbed page structure. There are around 5 tabs. 1 tabs has an entry. When I fill the entry, I want the other 4 tabs to show the entry in a label. How can I achieve this?

People usually say that you shouldn't bind multiple views to 1 viewmodel, each page should have it's own VM. If that's true, how can those views be updated? Should I refresh each tab when I navigate to it?

1

There are 1 answers

0
Mouse On Mars On BEST ANSWER

It sounds like you want to synchronize data between viewmodels. I would have the viewmodel with the entry publish the new updated value via the Xamarin Forms Messaging Center.

The other tabs viewmodels can subscribe to these changes and update their properties accordingly