diff --git a/samples/mavvmApp/AppShell.xaml b/samples/mavvmApp/AppShell.xaml index cd250e7..4ee97e2 100644 --- a/samples/mavvmApp/AppShell.xaml +++ b/samples/mavvmApp/AppShell.xaml @@ -4,13 +4,13 @@ xmlns="http://schemas.microsoft.com/dotnet/2021/maui" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:viewmodels="clr-namespace:mavvmApp.ViewModels" xmlns:mavvm="clr-namespace:mavvm;assembly=mavvm" x:Class="mavvmApp.AppShell"> - + - + - + diff --git a/samples/mavvmApp/ViewModels/MainPageViewModel.cs b/samples/mavvmApp/ViewModels/MainPageViewModel.cs index 800e074..89738d4 100644 --- a/samples/mavvmApp/ViewModels/MainPageViewModel.cs +++ b/samples/mavvmApp/ViewModels/MainPageViewModel.cs @@ -46,7 +46,7 @@ void CountUp() async void Navigate() { - await BaseMethods.GoToViewModel(false, new NavigationParameters{ { "countParam", Count } }); + await BaseMethods.GoToSection("main", new NavigationParameters{ { "countParam", Count } }); } } } diff --git a/src/mavvm/Navigation/BaseMethods.cs b/src/mavvm/Navigation/BaseMethods.cs index a237791..f8f11c4 100644 --- a/src/mavvm/Navigation/BaseMethods.cs +++ b/src/mavvm/Navigation/BaseMethods.cs @@ -37,13 +37,15 @@ public static async Task GoToSection(string sectionRoute, NavigationParameters p } else { - await Shell.Current.GoToAsync(path, animate, parameters); + await Shell.Current.GoToAsync(path, false, parameters); - if ((Shell.Current?.CurrentItem?.CurrentItem as IShellSectionController)?.PresentedPage.BindingContext is INavigateBackToAware vm) + //HACK: Shell doesn'T immediately know about PresentedPage. + await Task.Delay(50); + + if ((Shell.Current?.CurrentItem?.CurrentItem as IShellSectionController)?.PresentedPage?.BindingContext is INavigateToAware vmTo) { - vm.NavigatedBackTo(parameters); + vmTo.NavigatedTo(parameters); } - } }