summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Smith <jason.smith@xamarin.com>2016-10-12 19:45:06 (GMT)
committerJason Smith <jason.smith@xamarin.com>2016-10-12 19:46:22 (GMT)
commitb39cd18d627e1a69e52aa2a099029f30db4823ec (patch)
tree1d8a4efdb83e8dc9b761cc96675d072772591ef2
parente52e81d5c05f628b30676cd882e672a05189cbf5 (diff)
downloadxamarin-forms-b39cd18d627e1a69e52aa2a099029f30db4823ec.zip
xamarin-forms-b39cd18d627e1a69e52aa2a099029f30db4823ec.tar.gz
xamarin-forms-b39cd18d627e1a69e52aa2a099029f30db4823ec.tar.bz2
[A]Don't crash when emptying/populating TabbedPage.ItemsSource (#427)
-rw-r--r--Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla44129.cs55
-rw-r--r--Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems3
-rw-r--r--Xamarin.Forms.Platform.Android/AppCompat/TabbedPageRenderer.cs4
3 files changed, 61 insertions, 1 deletions
diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla44129.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla44129.cs
new file mode 100644
index 0000000..e1755ef
--- /dev/null
+++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla44129.cs
@@ -0,0 +1,55 @@
+´╗┐using System;
+using System.Collections.ObjectModel;
+using Xamarin.Forms.CustomAttributes;
+using Xamarin.Forms.Internals;
+
+#if UITEST
+using Xamarin.UITest;
+using NUnit.Framework;
+#endif
+
+namespace Xamarin.Forms.Controls
+{
+ [Preserve(AllMembers = true)]
+ [Issue(IssueTracker.Bugzilla, 44129, "Crash when adding tabbed page after removing all pages using DataTemplates")]
+ public class Bugzilla44129 : TestTabbedPage // or TestMasterDetailPage, etc ...
+ {
+ protected override void Init()
+ {
+ // Initialize ui here instead of ctor
+ var viewModels = new ObservableCollection<string>();
+ viewModels.Add("First");
+ viewModels.Add("Second");
+ var template = new DataTemplate(() =>
+ {
+ ContentPage page = new ContentPage();
+ var crashMe = new Button { Text = "Crash Me" };
+ crashMe.Clicked += (sender, args) =>
+ {
+ viewModels.Clear();
+ viewModels.Add("Third");
+ };
+
+ page.Content = crashMe;
+ page.SetBinding(ContentPage.TitleProperty, ".");
+
+ return page;
+ });
+
+ ItemTemplate = template;
+ ItemsSource = viewModels;
+ }
+
+#if UITEST
+ [Test]
+ public void Issue44129Test ()
+ {
+ RunningApp.Screenshot ("I am at Issue 1");
+ RunningApp.WaitForElement (q => q.Marked ("First"));
+ RunningApp.Screenshot ("I see the Label");
+ RunningApp.Tap(q => q.Marked("Second"));
+ RunningApp.Tap(q => q.Marked("Crash Me"));
+ }
+#endif
+ }
+} \ No newline at end of file
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 c0c8922..d7920f5 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
@@ -185,6 +185,9 @@
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla42602.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla43161.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla39768.cs" />
+ <Compile Include="$(MSBuildThisFileDirectory)Bugzilla41271.cs" />
+ <Compile Include="$(MSBuildThisFileDirectory)Bugzilla41153.cs" />
+ <Compile Include="$(MSBuildThisFileDirectory)Bugzilla44129.cs" />
<Compile Include="$(MSBuildThisFileDirectory)_Template.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue1028.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue1075.cs" />
diff --git a/Xamarin.Forms.Platform.Android/AppCompat/TabbedPageRenderer.cs b/Xamarin.Forms.Platform.Android/AppCompat/TabbedPageRenderer.cs
index ca0f733..5f36431 100644
--- a/Xamarin.Forms.Platform.Android/AppCompat/TabbedPageRenderer.cs
+++ b/Xamarin.Forms.Platform.Android/AppCompat/TabbedPageRenderer.cs
@@ -249,7 +249,7 @@ namespace Xamarin.Forms.Platform.Android.AppCompat
TabLayout tabs = _tabLayout;
((FormsFragmentPagerAdapter<Page>)pager.Adapter).CountOverride = Element.Children.Count;
- pager.Adapter.NotifyDataSetChanged();
+
if (Element.Children.Count == 0)
tabs.RemoveAllTabs();
@@ -260,6 +260,8 @@ namespace Xamarin.Forms.Platform.Android.AppCompat
tabs.SetOnTabSelectedListener(this);
}
+ pager.Adapter.NotifyDataSetChanged();
+
UpdateIgnoreContainerAreas();
}