Skip to content
This repository was archived by the owner on Apr 23, 2023. It is now read-only.

Commit 6877f14

Browse files
integrate back button
1 parent d283d1e commit 6877f14

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

Xamarin/BooksAppX/BooksAppX/BooksAppX.UWP/BooksAppX.UWP.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@
157157
<Version>2.0.0</Version>
158158
</PackageReference>
159159
<PackageReference Include="Xamarin.Forms" Version="2.5.0.122203" />
160-
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform" Version="6.0.1" />
160+
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform" Version="6.0.6" />
161161
</ItemGroup>
162162
<ItemGroup>
163163
<ProjectReference Include="..\..\..\..\PatternsXamarinShared\BooksLib\BooksLib.csproj">

Xamarin/BooksAppX/BooksAppX/BooksAppX/App.xaml.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public App()
2323
protected override void OnStart()
2424
{
2525
// Handle when your app starts
26+
AppServices.GetService<INavigationService>().UseNavigation = true; // always use navigation
2627
}
2728

2829
protected override void OnSleep()

Xamarin/BooksAppX/BooksAppX/BooksAppX/Views/MainPage.xaml.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
using Microsoft.Extensions.DependencyInjection;
55
using BooksAppX.Services;
66
using BooksLib.Services;
7+
using Framework.Services;
8+
using System.Threading.Tasks;
79

810
namespace BooksAppX.Views
911
{
@@ -16,5 +18,16 @@ public MainPage ()
1618

1719
(Application.Current as App).AppServices.GetService<XamarinInitializeNavigationService>().SetNavigation(navigationPage.Navigation, PageNames.BooksPage);
1820
}
21+
22+
protected override bool OnBackButtonPressed()
23+
{
24+
OnBackButtonAsync();
25+
return true;
26+
}
27+
28+
private async void OnBackButtonAsync()
29+
{
30+
await (Application.Current as App).AppServices.GetService<INavigationService>().GoBackAsync();
31+
}
1932
}
2033
}

0 commit comments

Comments
 (0)