-
Register the service.
1
services.AddSingleton<AppShell, ShellViewModel>();
-
Modify
App.xaml.cs
.1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
public App() { InitializeComponent(); MauiExceptions.UnhandledException += (sender, args) => { Exception? exception = args.ExceptionObject as Exception; }; } protected override Window CreateWindow(IActivationState? activationState) { AppShell? appShell = activationState?.Context.Services.GetService<AppShell>(); Window window = new(appShell!); return window; }