diff --git a/TransactionProcessor.Mobile/Extensions/MauiAppBuilderExtensions.cs b/TransactionProcessor.Mobile/Extensions/MauiAppBuilderExtensions.cs index cf794de8..0614b56d 100644 --- a/TransactionProcessor.Mobile/Extensions/MauiAppBuilderExtensions.cs +++ b/TransactionProcessor.Mobile/Extensions/MauiAppBuilderExtensions.cs @@ -176,6 +176,8 @@ public static HttpMessageHandler GetHandler() { public static MauiAppBuilder ConfigureUIServices(this MauiAppBuilder builder) { builder.Services.AddSingleton(); + builder.Services.AddTransient>(serviceProvider => + () => serviceProvider.GetRequiredService()); builder.Services.AddSingleton(); builder.Services.AddSingleton(); builder.Services.AddSingleton(); diff --git a/TransactionProcessor.Mobile/UIServices/ShellNavigationService.cs b/TransactionProcessor.Mobile/UIServices/ShellNavigationService.cs index 5dcde6b2..0252ea53 100644 --- a/TransactionProcessor.Mobile/UIServices/ShellNavigationService.cs +++ b/TransactionProcessor.Mobile/UIServices/ShellNavigationService.cs @@ -14,14 +14,14 @@ namespace TransactionProcessor.Mobile.UIServices; public class ShellNavigationService : INavigationService { private readonly INavigationParameterService NavigationParameterService; - private readonly IServiceProvider ServiceProvider; + private readonly Func MyAccountAddressesPageFactory; #region Methods public ShellNavigationService(INavigationParameterService navigationParameterService, - IServiceProvider serviceProvider) { + Func myAccountAddressesPageFactory) { this.NavigationParameterService = navigationParameterService; - this.ServiceProvider = serviceProvider; + this.MyAccountAddressesPageFactory = myAccountAddressesPageFactory; } public async Task QuitApplication(){ @@ -175,7 +175,7 @@ public async Task GoToViewLogsPage() { } public async Task GoToMyAccountAddresses() { - MyAccountAddressesPage p = this.ServiceProvider.GetRequiredService(); + MyAccountAddressesPage p = this.MyAccountAddressesPageFactory(); await this.NavigateTo(p); }