This commit is contained in:
Samantha Houts 2018-08-08 10:12:08 -07:00
Родитель 9ffa2f12c7 bbeb047084
Коммит bed2a0d2fa
3 изменённых файлов: 66 добавлений и 4 удалений

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

@ -0,0 +1,62 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms.CustomAttributes;
using Xamarin.Forms.Internals;
#if UITEST
using Xamarin.UITest;
using NUnit.Framework;
using Xamarin.Forms.Core.UITests;
#endif
namespace Xamarin.Forms.Controls.Issues
{
[Preserve(AllMembers = true)]
[Issue(IssueTracker.Github, 3507, "[UWP] Scrollview with null content crashes on UWP",
PlatformAffected.UWP)]
#if UITEST
[NUnit.Framework.Category(UITestCategories.ListView)]
#endif
public class Issue3507 : TestContentPage
{
Label label;
ScrollView scrollView;
protected override void Init()
{
scrollView = new ScrollView();
label = new Label();
Content = new StackLayout()
{
Children =
{
label,
scrollView
}
};
}
protected override async void OnAppearing()
{
base.OnAppearing();
await Task.Delay(500);
scrollView.Content = new StackLayout();
await Task.Delay(500);
scrollView.Content = null;
await Task.Delay(500);
label.Text = "Success";
}
#if UITEST
[Test]
public void NullContentOnScrollViewDoesntCrash()
{
RunningApp.WaitForElement("Success");
}
#endif
}
}

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

@ -369,6 +369,7 @@
<Compile Include="$(MSBuildThisFileDirectory)Issue3008.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue3019.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue2993.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue3507.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue3367.cs" />
<Compile Include="$(MSBuildThisFileDirectory)LegacyComponents\NonAppCompatSwitch.cs" />
<Compile Include="$(MSBuildThisFileDirectory)MapsModalCrash.cs" />

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

@ -133,7 +133,7 @@ namespace Xamarin.Forms.Platform.UWP
Control.Content = renderer != null ? renderer.ContainerElement : null;
UpdateMargins();
if(renderer.ContainerElement != null)
if (renderer?.ContainerElement != null)
renderer.ContainerElement.LayoutUpdated += SetInitialRtlPosition;
}
@ -175,7 +175,7 @@ namespace Xamarin.Forms.Platform.UWP
}
Element.SendScrollFinished();
}
void SetInitialRtlPosition(object sender, object e)
{
if (Control == null) return;
@ -200,8 +200,7 @@ namespace Xamarin.Forms.Platform.UWP
void ClearRtlScrollCheck()
{
_checkedForRtlScroll = true;
var element = (Control.Content as FrameworkElement);
if (element != null)
if (Control.Content is FrameworkElement element)
element.LayoutUpdated -= SetInitialRtlPosition;
}