I created an AppShell app, I customized the Shellcontent with a renderer in order to change the icon when it is clicked, the only problem is that the style of the tabbar that I had set in the resource dictionary is not calculated and therefore the tabbar is returned to default settings.
This is the code of the AppShell.xaml
<Shell.Resources>
<ResourceDictionary>
<Style x:Key="BaseStyle" TargetType="Element">
<Setter Property="Shell.TabBarBackgroundColor" Value="White" />
<!--<Setter Property="Shell.TabBarForegroundColor" Value="Black"/>-->
<Setter Property="Shell.NavBarIsVisible" Value="False"/>
<Setter Property="Shell.TabBarUnselectedColor" Value="{StaticResource Primary}"/>
<Setter Property="Shell.TabBarTitleColor" Value="{StaticResource Secondary}"/>
<!--<Setter Property="Shell.DisabledColor" Value="Green"/>-->
</Style>
<Style TargetType="TabBar" BasedOn="{StaticResource BaseStyle}"/>
</ResourceDictionary>
</Shell.Resources>
This is the code of Renderer
[assembly: ExportRenderer(typeof(AppShell), typeof(MyShellRenderer))]
namespace AFI.Droid { public class MyShellRenderer : ShellRenderer { public MyShellRenderer(Context context) : base(context) { }
protected override IShellBottomNavViewAppearanceTracker CreateBottomNavViewAppearanceTracker(ShellItem shellItem)
{
return new CustomBottomNavAppearance();
}
}
public class CustomBottomNavAppearance : IShellBottomNavViewAppearanceTracker
{
public void Dispose()
{
}
public void ResetAppearance(BottomNavigationView bottomView)
{
}
public void SetAppearance(BottomNavigationView bottomView, IShellAppearanceElement appearance)
{
//SETTARE IN BASE AI GRUPPI
IMenu myMenu = bottomView.Menu;
if (App.UTENTE == "Afi")
{
IMenuItem myItemOne = myMenu.GetItem(0);
if (myItemOne.IsChecked)
{
myItemOne.SetIcon(Resource.Drawable.Dashboard_hover);
}
else
{
myItemOne.SetIcon(Resource.Drawable.Dashboard);
}
Is there any way to make sure to keep the settings I have given in the style?