diff --git a/src/Controls/src/Core/Handlers/Shell/Windows/ShellView.cs b/src/Controls/src/Core/Handlers/Shell/Windows/ShellView.cs index eb6f4284e626..5bf6ab47fa0d 100644 --- a/src/Controls/src/Core/Handlers/Shell/Windows/ShellView.cs +++ b/src/Controls/src/Core/Handlers/Shell/Windows/ShellView.cs @@ -193,6 +193,12 @@ public override bool Equals(object obj) => internal void SwitchShellItem(ShellItem newItem, bool animate = true) { + if (newItem is null) + throw new InvalidOperationException("Active Shell Item not set. Have you added any Shell Items to your Shell?"); + + if (newItem.CurrentItem is null) + throw new InvalidOperationException($"Content not found for active {newItem}. Title: {newItem.Title}. Route: {newItem.Route}."); + var navItems = FlyoutItems.OfType(); // Implicit items aren't items that are surfaced to the user diff --git a/src/Controls/tests/DeviceTests/Elements/Shell/ShellTests.Windows.cs b/src/Controls/tests/DeviceTests/Elements/Shell/ShellTests.Windows.cs index b1932396b75a..505b9deec3c9 100644 --- a/src/Controls/tests/DeviceTests/Elements/Shell/ShellTests.Windows.cs +++ b/src/Controls/tests/DeviceTests/Elements/Shell/ShellTests.Windows.cs @@ -819,5 +819,21 @@ AnimatedIcon GetNativeAnimatedIcon(ShellHandler shellHandler) return animatedIcon; } + + [Fact(DisplayName = "Initialize Empty Shell Throws InvalidOperationException")] + public async Task InitializeEmptyShellThrowsInvalidOperationException() + { + SetupBuilder(); + + var shell = new Shell(); + + await Assert.ThrowsAsync(async () => + { + await CreateHandlerAndAddToWindow(shell, (handler) => + { + return Task.CompletedTask; + }); + }); + } } }