[UWP] Fixes IndexOutOfRangeException on TabbedPage (#6385)

* [UWP] Fixes IndexOutOfRangeException on TabbedPage

* add tab page category

* fix update colors

* optimization
This commit is contained in:
Pavel Yakovlev 2019-06-12 16:41:46 -07:00 коммит произвёл Shane Neuville
Родитель 15b01e5b68
Коммит ca8bd3fa71
5 изменённых файлов: 45 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,37 @@
using Xamarin.Forms.CustomAttributes;
using Xamarin.Forms.Internals;
using System;
#if UITEST
using NUnit.Framework;
#endif
namespace Xamarin.Forms.Controls.Issues
{
[Preserve(AllMembers = true)]
[Issue(IssueTracker.Github, 6323, "TabbedPage Page not watching icon changes", PlatformAffected.UWP)]
public class Issue6323 : TestTabbedPage
{
protected override void Init()
{
SelectedTabColor = Color.Purple;
Device.StartTimer(TimeSpan.FromSeconds(2), () =>
{
Children.Add(new ContentPage
{
Content = new Label { Text = "Success" },
Title = "I'm a title"
});
return false;
});
}
#if UITEST && __WINDOWS__
[Test]
public void Issue6323Test()
{
RunningApp.WaitForElement("Success");
}
#endif
}
}

Просмотреть файл

@ -518,6 +518,9 @@ namespace Xamarin.Forms.Controls
protected abstract void Init();
}
#if UITEST
[Category(UITestCategories.TabbedPage)]
#endif
public abstract class TestTabbedPage : TabbedPage
{
#if UITEST

Просмотреть файл

@ -861,6 +861,7 @@
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla41038.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla38284.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla39486.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue6323.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue55555.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla41029.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla39908.cs" />

Просмотреть файл

@ -48,5 +48,6 @@
public const string Visual = "Visual";
public const string AppLinks = "AppLinks";
public const string Shell = "Shell";
public const string TabbedPage = "TabbedPage";
}
}

Просмотреть файл

@ -287,6 +287,7 @@ namespace Xamarin.Forms.Platform.UWP
// Need to make sure any new items have the correct fore/background colors
ApplyBarBackgroundColor(true);
ApplyBarTextColor(true);
UpdateSelectedTabColors();
break;
}
}
@ -555,6 +556,8 @@ namespace Xamarin.Forms.Platform.UWP
{
// Retrieve all tab header textblocks
var allTabHeaderTextBlocks = Control.GetDescendantsByName<WTextBlock>(TabBarHeaderTextBlockName).ToArray();
if (allTabHeaderTextBlocks.Length != Control.Items.Count)
return;
// Loop through all pages in the Pivot control
foreach (Page page in Control.Items)