Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

Xamarin.Forms MessagingCenter to update Pages BindingContext and PopAsync

$
0
0

Hi Guys,

i have the following situation:

      private async void UpdateKundenDatenInOverviewPage(KundenDatenPageModel e)
                        {
                            initializerModel.KundenDaten = e;
                
                            BindingContext = initializerModel;
                
                            await Navigation.PopAsync();
                        }

This Method gets invoked by a Message my Page subscribes from. The initializerModel is a class member and gets initialized once in the constructor of the page with default values. After the message was sent i want to update the KundenDaten Property of the initializerModel in order to bind the new data to the page again. But it wont work.

            private async void UpdateKundenDatenInOverviewPage(KundenDatenPageModel e)
            {
                OverviewPageModel initializerModel = new OverviewPageModel();
                initializerModel .KundenDaten = e;
                initializerModel .FahrzeugZustand = fahrzeugZustand;

                BindingContext = initializerModel;

                await Navigation.PopAsync();
            }

This code works. So if i create a new instance of initializerModel (in this case its a OverviewPageModel) and set it as the pages BindingContext the data will appear after i pop the page the message was sent from from the navigationstack.

Can u guys help me?
Thank you in advance, Gelatto


Viewing all articles
Browse latest Browse all 77050

Trending Articles