Exemple #1
0
        public IXFPopupCtrl CreateDropDown(Xamarin.Forms.View anchor, Xamarin.Forms.View drop)
        {
            CustomDropDown dropctr = null;

            //get the renderer of anchor
            if (anchor != null)
            {
                var ar = anchor.GetValue(RendererProperty);
                if (ar != null)
                {
                    var dropView = Convert(drop, anchor);

                    if (dropView == null)
                    {
                        return(null);
                    }

                    double w = (int)anchor.Width;
                    double h = XFPopupConst.SCREEN_HEIGHT / 2;
                    drop.WidthRequest = w;
                    var size = drop.GetSizeRequest(w, XFPopupConst.SCREEN_HEIGHT / 2);
                    if (size.Request.Height < h)
                    {
                        h = size.Request.Height;
                    }


                    drop.Layout(new Rectangle(0, 0, w, h));

                    float density = Forms.Context.Resources.DisplayMetrics.Density;
                    w = w * density;
                    h = h * density;


                    var native = dropView as Android.Views.View;
                    native.LayoutParameters = new ViewGroup.LayoutParams((int)w, (int)h);

                    dropctr = new CustomDropDown(ar as Android.Views.View, native, (int)w + 4, (int)h + 10);
                }
            }

            return(dropctr);
        }
        public IXFPopupCtrl CreateDropDown(Xamarin.Forms.View anchor, Xamarin.Forms.View drop)
        {
            CustomDropDown dropctr = null;
            //get the renderer of anchor
            if (anchor != null) {
                var ar = anchor.GetValue(RendererProperty);
                if (ar != null) {
                    var dropView = Convert(drop, anchor);

                    if (dropView == null) {
                        return null;
                    }

                    double w = (int)anchor.Width;
                    double h = XFPopupConst.SCREEN_HEIGHT/2;
                    drop.WidthRequest = w;
                    var size = drop.GetSizeRequest(w, XFPopupConst.SCREEN_HEIGHT / 2);
                    if (size.Request.Height < h) {
                        h = size.Request.Height;
                    }

                    drop.Layout(new Rectangle(0, 0, w, h));

                    float density = Forms.Context.Resources.DisplayMetrics.Density;
                    w = w * density;
                    h = h * density;

                    var native = dropView as Android.Views.View;
                    native.LayoutParameters = new ViewGroup.LayoutParams((int)w, (int)h);

                    dropctr = new CustomDropDown(ar as Android.Views.View, native, (int)w + 4, (int)h+10);

                }

            }

            return dropctr;
        }