Пример #1
0
        public IXFPopupCtrl CreateDialog(Page page, Xamarin.Forms.View content,bool cancelable)
        {
            CustomDialog dlg = null;
            //first try to get the PopupHolderRenderer

            if (content != null) {

                var render = Convert(content, page);

                if (render != null) {

                    var size = content.GetSizeRequest(XFPopupConst.SCREEN_WIDTH, XFPopupConst.SCREEN_HEIGHT);

                    var width = (int)size.Request.Width;
                    var height = (int)size.Request.Height;

                    if (width > XFPopupConst.SCREEN_WIDTH)
                    {
                        width = (int)(XFPopupConst.SCREEN_WIDTH * 3 / 4);
                    }

                    if (height > (XFPopupConst.SCREEN_HEIGHT * 3/ 4))
                    {
                        height = (int)(XFPopupConst.SCREEN_HEIGHT * 3/ 4);
                    }

                    //important
                    content.Layout(new Rectangle(0, 0, width, height));

                    float density = Forms.Context.Resources.DisplayMetrics.Density;
                    width = (int)(width * density);
                    height = (int)(height * density);

                    var native = render as Android.Views.View;
                    native.LayoutParameters = new ViewGroup.LayoutParams(width, height);

                    LinearLayout ll = new LinearLayout(Forms.Context);
                    ll.SetBackgroundResource(Resource.Layout.rounded_rectangle_bgr);
                    ll.LayoutParameters = new ViewGroup.LayoutParams(width + 4, height + 4);
                    ll.AddView(native);

                    dlg = new CustomDialog(ll,cancelable);

                }

            }
            return dlg;
        }