0

I want users entering data across multiple tabs to be able to see at a glance whether and where they have validation errors / fields not populated. I can indicate errors for the selected form in the form body, but for unselected tabs I want to use red color and/or a red icon in the tab to indicate if it is failing validation.

I see various posts explaining how to use a custom renderer or effect to set tab text color for all tabs or selected/unselected tabs (e.g. here, here, here modifying the framework itself and here). However, the posts I've seen do not show a way to change the color of a SPECIFIC tab. In this case I want to either change the color or add/remove an error icon that would show beside the Title in the tab header based on the validation results for the page accessed via the tab. Is that possible?

Update: I also found this - seemed more promising because it does seem to change tabs based on their positions or title rather than just on whether they were selected or not, but it seems to be dependent on using bottom tabs, which I'm not doing.

I also have found this, and element.Children[i] does get me the ContentPage from which I can determine what color I want the tab's test to be, and it's possible that the tab variable that's returned by activity.ActionBar.GetTabAt(i) somehow gives me access to update the tab's text color, but I'm not seeing any method or property that seems promising - basically I still don't see how to get access to the UITabBarItem so I can call SetTitleAndAttributes on it to set its text color. (Also, if I declare the tab variable by its type of Android.App.ActionBar.Tab instead of using var, I get a note saying that type has been deprecated. It seems upon investigation that the whole ActionBar class has been deprecated. But how can that be when it still exists as a property of Android.App.Activity, which is not deprecated?)

Many thanks for your assistance!

user756366
  • 467
  • 6
  • 24
  • If you want to change selected tabbedpage tab text color and image color, you can follow the last link that you provide.You can try it firstly. – Cherry Bu - MSFT Jun 05 '20 at 02:12
  • I am trying, but am unfortunately not finding it at all helpful thus far. My breakpoint in OnElementChanged is hit when the tabbed page loads, but the code from that post isn't helping me to change the font color. I'm not using a bottom navigation menu, but just normal tabs at the top of the form. GetChildAt(0) returns a Xamarin.Forms.Platform.Android.PageRenderer. That does not seem to have a GetChildAt method. I have no idea how to get access to any object I could use to set the color or text of the tabs. – user756366 Jun 05 '20 at 19:55
  • Is your newest issue moved to this thread?: https://stackoverflow.com/questions/62272149/in-xamarin-app-tabs-from-tabbedview-not-populated-at-the-same-time-in-android-t – Leon Jun 10 '20 at 09:11
  • Yes - sorry, maybe I should have just edited this thread, but I was discouraged at no responses here and felt that if I just edited existing thread, no one would see the edit and respond. I also still would be just as happy to change text color - that other thread is just as far as I have been able to get with icons. – user756366 Jun 10 '20 at 16:14

0 Answers0