Xamarin forms: Change color of app navigation bar button item after completion of bacground task RRS feed

  • Question

  • User172628 posted

    I have a functionality in my Xamarin form based application where I am working on sync task, I want to show the user the current progress of the sync throughout the application in the application navigation bar.

    Irrespective of whatever view the user is currently seeing if the background sync activity is completed the navigation bar button icon should change from yellow to green indicating that the sync is completed and if it fails it should change from yellow to red.

    My application is currently being worked for UWP and in future it will support for iOS and Android, first I would like to know if this kind of feature is doable or not in Xamarin forms, if its doable I would like to know the steps.

    My Solution: As of now I have shown a modal view on the tap of navigation bar button, the modal view has a progress bar which shows the status of the background sync using events and delegates pattern, but my client wants to change the color of the navigation bar button rather than displaying another modal view.

    Requesting you to provide guidance on the same.

    Monday, May 23, 2016 6:16 AM

All replies

  • User56015 posted

    Hi there,

    Everything is possible with Forms, but it might require som extra work ;-). For this type of custom stuff you might need a renderer to accomplish this using native Xamarin code. You could also check out the new effects feature of Xamarin.Forms.

    iOS also has a uiappearance which lets you manipulate UI on a global level. There are many ways of doing this.. What I would do is:

    • Create a custom NavigationPage
    • Create a renderer for that NavigationPage
    • Inside the renderer add a method or event that updates the color of the button
    • Call the method whenever you need the color to change.
    Monday, May 23, 2016 8:54 AM