Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Commit

Permalink
Throw exception when ViewCell View is null (#752)
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmgarrido authored and rmarinho committed Mar 3, 2017
1 parent 81058db commit 97b28b1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Xamarin.Forms.Platform.Android/Cells/ViewCellRenderer.cs
Expand Up @@ -2,6 +2,7 @@
using Android.Views;
using AView = Android.Views.View;
using Xamarin.Forms.Internals;
using System;

namespace Xamarin.Forms.Platform.Android
{
Expand Down Expand Up @@ -32,6 +33,9 @@ protected override AView GetCellCore(Cell item, AView convertView, ViewGroup par
rowHeight = ListView.RowHeightProperty;
}

if (cell.View == null)
throw new InvalidOperationException($"ViewCell must have a {nameof(cell.View)}");

IVisualElementRenderer view = Platform.CreateRenderer(cell.View);
Platform.SetRenderer(cell.View, view);
cell.View.IsPlatformEnabled = true;
Expand Down
3 changes: 3 additions & 0 deletions Xamarin.Forms.Platform.iOS/Cells/ViewCellRenderer.cs
Expand Up @@ -139,6 +139,9 @@ protected override void Dispose(bool disposing)

IVisualElementRenderer GetNewRenderer()
{
if (_viewCell.View == null)
throw new InvalidOperationException($"ViewCell must have a {nameof(_viewCell.View)}");

var newRenderer = Platform.CreateRenderer(_viewCell.View);
_rendererRef = new WeakReference<IVisualElementRenderer>(newRenderer);
ContentView.AddSubview(newRenderer.NativeView);
Expand Down

0 comments on commit 97b28b1

Please sign in to comment.