Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 91519

Render a ContentPage inside an AlertDialog or DialogFragment

$
0
0

Hi Xamarin Devs,

Is it possible to display a ContentPage inside a DialogFragment or AlertDialog?
My problem is that when I try to get the renderer of a ContentPage, it throws an error.
Here's how i'm doing it:

            var page = new CommentPage(); //a ContentPage defined in xaml
            var renderer = RendererFactory.GetRenderer (page);//This throws an error
                Console.WriteLine("renderer");
                Utils.RequestMainThread (() => {
                    var builder = new AlertDialog.Builder (MainActivity.Instance).SetView (renderer as VisualElementRenderer<Xamarin.Forms.View> );

                    var dialog = builder.Create ();
                    renderer.UpdateLayout();
                    dialog.Window.SetSoftInputMode (SoftInput.StateVisible);
                    dialog.Show ();

                });

This is the error:
Attempt to invoke virtual method 'android.content.res.Resources android.content.Context.getResources()' on a null object reference
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Users/builder/data/lanes/2098/3efa14c4/source/mono/external/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143
at Android.Runtime.JNIEnv.CallNonvirtualVoidMethod (IntPtr jobject, IntPtr jclass, IntPtr jmethod, Android.Runtime.JValue* parms) [0x00084] in /Users/builder/data/lanes/2098/3efa14c4/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs:1029
..................


Viewing all articles
Browse latest Browse all 91519

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>