From e291e7ef5a4b8af630a4e03b1a51e6239e6ae57c Mon Sep 17 00:00:00 2001 From: Gerald Versluis Date: Mon, 11 Apr 2022 16:23:50 +0200 Subject: [PATCH] Fix NRE VisualElement Background when is null (#15299) --- Xamarin.Forms.Core/VisualElement.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Xamarin.Forms.Core/VisualElement.cs b/Xamarin.Forms.Core/VisualElement.cs index 3531c56df11..6330f594efd 100644 --- a/Xamarin.Forms.Core/VisualElement.cs +++ b/Xamarin.Forms.Core/VisualElement.cs @@ -218,7 +218,10 @@ void NotifyBackgroundChanges() { Device.InvokeOnMainThreadAsync(() => { - Background.Parent = this; + if (Background != null) + { + Background.Parent = this; + } }); Background.PropertyChanged += OnBackgroundChanged;