diff --git a/src/Controls/src/Core/Compatibility/Handlers/Shell/Android/ShellToolbarAppearanceTracker.cs b/src/Controls/src/Core/Compatibility/Handlers/Shell/Android/ShellToolbarAppearanceTracker.cs index 11deb5ac0b18..4ab85e30e61f 100644 --- a/src/Controls/src/Core/Compatibility/Handlers/Shell/Android/ShellToolbarAppearanceTracker.cs +++ b/src/Controls/src/Core/Compatibility/Handlers/Shell/Android/ShellToolbarAppearanceTracker.cs @@ -33,9 +33,17 @@ public virtual void ResetAppearance(AToolbar toolbar, IShellToolbarTracker toolb protected virtual void SetColors(AToolbar toolbar, IShellToolbarTracker toolbarTracker, Color foreground, Color background, Color title) { - _shellContext.Shell.Toolbar.BarTextColor = title ?? ShellRenderer.DefaultTitleColor; - _shellContext.Shell.Toolbar.BarBackground = new SolidColorBrush(background ?? ShellRenderer.DefaultBackgroundColor); - _shellContext.Shell.Toolbar.IconColor = foreground ?? ShellRenderer.DefaultForegroundColor; + if (_disposed) + return; + + Toolbar shellToolbar = _shellContext?.Shell?.Toolbar; + + if (shellToolbar is null) + return; + + shellToolbar.BarTextColor = title ?? ShellRenderer.DefaultTitleColor; + shellToolbar.BarBackground = new SolidColorBrush(background ?? ShellRenderer.DefaultBackgroundColor); + shellToolbar.IconColor = foreground ?? ShellRenderer.DefaultForegroundColor; } #region IDisposable