summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul DiPietro <paul.dipietro@me.com>2016-05-26 15:14:56 -0400
committerkingces95 <kingces95@users.noreply.github.com>2016-05-26 12:14:56 -0700
commitb17cb55f5710cfc14a4dbfe0182e94df47d83bd3 (patch)
tree6a85c90a1f6ce7a0838c45394977070174ce4568
parent349336dbf12fb158f7731ece7fb1524cb1f5808a (diff)
downloadxamarin-forms-b17cb55f5710cfc14a4dbfe0182e94df47d83bd3.tar.gz
xamarin-forms-b17cb55f5710cfc14a4dbfe0182e94df47d83bd3.tar.bz2
xamarin-forms-b17cb55f5710cfc14a4dbfe0182e94df47d83bd3.zip
[8.1/UWP] Fix PopToRootAsync functioning incorrectly (#185)
When using PopToRootAsync on 8.1/UWP, the stack was being cleared but the actual page was not being set due to a missing event handler on the NavigationPageRenderer.
-rw-r--r--Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla31806.cs55
-rw-r--r--Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems1
-rw-r--r--Xamarin.Forms.Platform.WinRT/NavigationPageRenderer.cs7
3 files changed, 63 insertions, 0 deletions
diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla31806.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla31806.cs
new file mode 100644
index 00000000..60c68a03
--- /dev/null
+++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla31806.cs
@@ -0,0 +1,55 @@
+using System;
+
+using Xamarin.Forms.CustomAttributes;
+using Xamarin.Forms.Internals;
+
+#if UITEST
+using Xamarin.UITest;
+using NUnit.Framework;
+#endif
+
+namespace Xamarin.Forms.Controls.Issues
+{
+ [Preserve(AllMembers = true)]
+ [Issue(IssueTracker.Bugzilla, 31806, "[8.1/UWP] PopToRootAsync crashes due to not setting the current page correctly", PlatformAffected.WinRT)]
+ public class Bugzilla31806 : TestContentPage
+ {
+ protected override void Init()
+ {
+ Content = new StackLayout
+ {
+ Children =
+ {
+ new Button
+ {
+ Text = "Navigate to a new page",
+ Command = new Command(() =>
+ {
+ Navigation.PushAsync(new ContentPage
+ {
+ Content = new StackLayout
+ {
+ Children =
+ {
+ new Label
+ {
+ Text = "Pressing this button should let the navigation return to the repro list"
+ },
+ new Button
+ {
+ Text = "Call PopToRootAsync()",
+ Command = new Command(() =>
+ {
+ Navigation.PopToRootAsync();
+ })
+ }
+ }
+ }
+ });
+ })
+ }
+ }
+ };
+ }
+ }
+}
diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems
index 48ab47ad..fdeb7592 100644
--- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems
+++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems
@@ -102,6 +102,7 @@
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla39821.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla40185.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla40333.cs" />
+ <Compile Include="$(MSBuildThisFileDirectory)Bugzilla31806.cs" />
<Compile Include="$(MSBuildThisFileDirectory)CarouselAsync.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla34561.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla34727.cs" />
diff --git a/Xamarin.Forms.Platform.WinRT/NavigationPageRenderer.cs b/Xamarin.Forms.Platform.WinRT/NavigationPageRenderer.cs
index 9fe59bad..6e8edf52 100644
--- a/Xamarin.Forms.Platform.WinRT/NavigationPageRenderer.cs
+++ b/Xamarin.Forms.Platform.WinRT/NavigationPageRenderer.cs
@@ -157,6 +157,7 @@ namespace Xamarin.Forms.Platform.WinRT
{
((INavigationPageController)oldElement).PushRequested -= OnPushRequested;
((INavigationPageController)oldElement).PopRequested -= OnPopRequested;
+ ((INavigationPageController)oldElement).PopToRootRequested -= OnPopToRootRequested;
oldElement.InternalChildren.CollectionChanged -= OnChildrenChanged;
oldElement.PropertyChanged -= OnElementPropertyChanged;
}
@@ -187,6 +188,7 @@ namespace Xamarin.Forms.Platform.WinRT
Element.PropertyChanged += OnElementPropertyChanged;
((INavigationPageController)Element).PushRequested += OnPushRequested;
((INavigationPageController)Element).PopRequested += OnPopRequested;
+ ((INavigationPageController)Element).PopToRootRequested += OnPopToRootRequested;
Element.InternalChildren.CollectionChanged += OnChildrenChanged;
if (!string.IsNullOrEmpty(Element.AutomationId))
@@ -377,6 +379,11 @@ namespace Xamarin.Forms.Platform.WinRT
SetPage(newCurrent, e.Animated, true);
}
+ void OnPopToRootRequested(object sender, NavigationRequestedEventArgs e)
+ {
+ SetPage(e.Page, e.Animated, true);
+ }
+
void OnPushRequested(object sender, NavigationRequestedEventArgs e)
{
SetPage(e.Page, e.Animated, false);