From 5d9c2649f4e9f6b1b233b542140b1910a864f404 Mon Sep 17 00:00:00 2001 From: dylanberry Date: Wed, 15 Jan 2020 20:03:45 -0500 Subject: [PATCH] Fixed null reference exception Invalid safe cast from ContextThemeWrapper to FormsAppCompatActivity caused NullReferenceException in Xamarin.Forms 4.4 --- SettingsView.Droid/Cells/CellBaseView.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/SettingsView.Droid/Cells/CellBaseView.cs b/SettingsView.Droid/Cells/CellBaseView.cs index ebcdb74..d7f87fe 100644 --- a/SettingsView.Droid/Cells/CellBaseView.cs +++ b/SettingsView.Droid/Cells/CellBaseView.cs @@ -99,7 +99,8 @@ public CellBaseView(Context context, Cell cell) : base(context) void CreateContentView() { - var contentView = (_Context as FormsAppCompatActivity).LayoutInflater.Inflate(Resource.Layout.CellBaseView, this, true); + var layoutInflater = (LayoutInflater)_Context.GetSystemService(Context.LayoutInflaterService); + var contentView = layoutInflater.Inflate(Resource.Layout.CellBaseView, this, true); contentView.LayoutParameters = new ViewGroup.LayoutParams(-1, -1);