Forum Xamarin.Forms

Announcement:

The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

How to Refresh the Bindings on Page1 when some data has been changed in Navigated Page2

rajput400rajput400 Member ✭✭
edited January 3 in Xamarin.Forms

Hi Guys,

I have some property which I am using from Page2 in Page1ViewModel, When I navigate to Page2 I have changed that property and on coming back by doing NavigiationPop.
Page1is not re-loaded/ refreshed at all as I have set the BindingContext in the constructor of Page1, which is loaded only once.

The solution which is working for me is
Setting the BindingContext to the ViewModel on "onAppearing()", usually its not consider the best practice. But I also need to refresh the values which I have changed on Page2.

Looking forward for your valuable inputs and suggestions.
Also Pros/Cons of Setting the BindingContext in OnAppearing.

Thanks,
Hemant

Answers

  • AlessandroCaliaroAlessandroCaliaro ITMember ✭✭✭✭✭
    I think you can pass the first view model to the second page using its constructor. If you change the view model in the second page, you should see changes in the first page.

    I set the BindingContext in the page constructor
  • ColeXColeX Member, Xamarin Team Xamurai

    Hi ,@ rajput400 Was the problem solved or not ?

Sign In or Register to comment.