Changing Toolbar's Back Button Programmatically is lost on Android when a page is popped

时间:2018-01-23 19:26:15

标签: c# android xamarin.forms freshmvvm

XF 2.5 with FreshMVVM 2.2.3

I am calling a dependency service when pushing a new page to update back button colour as such:

FormsAppCompatActivity activity = (FormsAppCompatActivity)CrossCurrentActivity.Current.Activity;
Toolbar toolbar = activity.FindViewById<Toolbar>(Resource.Id.toolbar);
toolbar?.NavigationIcon?.SetColorFilter(foregroundColour.ToAndroid(), PorterDuff.Mode.SrcIn);

Then I am losing my new colour changes on Android only when I pop the previous page (that is not showing anymore).

  • If I don't pop the previous page, then the colour stays as expected
  • If I set the colour after the pop, that doesn't work
  • If I set the colour in the Init of the new page, that doesn't work
  • If I set the colour in the ViewIsAppearing (FreshMVVM) of the new page, that doesn't work
  • If I set the colour after two seconds on the Init of the new page using Device.StartTimer then that works!

My hunch is that I need to find a later event to set the colour but I am not sure there is one after ViewIsAppearing

Any suggestion on how to make the back button colour change permanently?

0 个答案:

没有答案