--- /dev/null
+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();
+ })
+ }
+ }
+ }
+ });
+ })
+ }
+ }
+ };
+ }
+ }
+}
<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" />
{
((INavigationPageController)oldElement).PushRequested -= OnPushRequested;
((INavigationPageController)oldElement).PopRequested -= OnPopRequested;
+ ((INavigationPageController)oldElement).PopToRootRequested -= OnPopToRootRequested;
oldElement.InternalChildren.CollectionChanged -= OnChildrenChanged;
oldElement.PropertyChanged -= OnElementPropertyChanged;
}
Element.PropertyChanged += OnElementPropertyChanged;
((INavigationPageController)Element).PushRequested += OnPushRequested;
((INavigationPageController)Element).PopRequested += OnPopRequested;
+ ((INavigationPageController)Element).PopToRootRequested += OnPopToRootRequested;
Element.InternalChildren.CollectionChanged += OnChildrenChanged;
if (!string.IsNullOrEmpty(Element.AutomationId))
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);