Fixes _child.Element null reference exception (#5756)

* Fixes _child.Element null reference exception

* Update ListViewRenderer.cs

fixes #5700
This commit is contained in:
Carbaholic 2019-04-29 15:37:41 -06:00 коммит произвёл Samantha Houts
Родитель 37c22eb1cb
Коммит 123ecf7619
1 изменённых файлов: 3 добавлений и 3 удалений

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

@ -501,7 +501,7 @@ namespace Xamarin.Forms.Platform.Android
protected override void OnMeasure(int widthMeasureSpec, int heightMeasureSpec) protected override void OnMeasure(int widthMeasureSpec, int heightMeasureSpec)
{ {
if (_child == null) if (_child?.Element == null)
{ {
SetMeasuredDimension(0, 0); SetMeasuredDimension(0, 0);
return; return;
@ -513,8 +513,8 @@ namespace Xamarin.Forms.Platform.Android
var width = (int)ctx.FromPixels(MeasureSpecFactory.GetSize(widthMeasureSpec)); var width = (int)ctx.FromPixels(MeasureSpecFactory.GetSize(widthMeasureSpec));
SizeRequest request = _child.Element.Measure(width, double.PositiveInfinity, MeasureFlags.IncludeMargins); SizeRequest request = element.Measure(width, double.PositiveInfinity, MeasureFlags.IncludeMargins);
Xamarin.Forms.Layout.LayoutChildIntoBoundingRegion(_child.Element, new Rectangle(0, 0, width, request.Request.Height)); Xamarin.Forms.Layout.LayoutChildIntoBoundingRegion(element, new Rectangle(0, 0, width, request.Request.Height));
int widthSpec = MeasureSpecFactory.MakeMeasureSpec((int)ctx.ToPixels(width), MeasureSpecMode.Exactly); int widthSpec = MeasureSpecFactory.MakeMeasureSpec((int)ctx.ToPixels(width), MeasureSpecMode.Exactly);
int heightSpec = MeasureSpecFactory.MakeMeasureSpec((int)ctx.ToPixels(request.Request.Height), MeasureSpecMode.Exactly); int heightSpec = MeasureSpecFactory.MakeMeasureSpec((int)ctx.ToPixels(request.Request.Height), MeasureSpecMode.Exactly);