public CustomAlertDialog(Context context) : base(context)
        {
            _layout = View.Inflate(Context, Resource.Layout.customDialog, null);

            // Вместо android:padding = "?android:attr/dialogPreferredPadding" в customDialog.axml для API < 22.
            Int32 paddingInPx = Build.VERSION.SdkInt < BuildVersionCodes.LollipopMr1
                ? Context.Resources.GetDimensionPixelSize(Resource.Dimension.dialogContentPaddingApiLevelLess22)
                : UiUtilities.GetAttributePixelSize(Context, Resource.Attribute.dialogPreferredPadding);

            _layout.SetPadding(paddingInPx, paddingInPx, paddingInPx, _layout.PaddingBottom);

            SetView(_layout);

            _content = _layout.FindViewById <FrameLayout>(Resource.Id.customDialogContentFrameLayout);
        }
        //private class ScrollChangeListener : Java.Lang.Object, View.IOnScrollChangeListener
        //{
        //    public event Action<Int32> ScrollChanged;
        //
        //    public void OnScrollChange(View view, Int32 scrollX, Int32 scrollY, Int32 oldScrollX, Int32 oldScrollY)
        //    {
        //        ScrollChanged?.Invoke(scrollY);
        //    }
        //}

        public CustomAlertDialog(Context context) : base(context)
        {
            // Вместо "?android:attr/dialogPreferredPadding" в customDialogLayout.axml для уровней API ниже 22.
            _preferredPadding = Build.VERSION.SdkInt < BuildVersionCodes.LollipopMr1
                ? Context.Resources.GetDimensionPixelSize(Resource.Dimension.dialogPreferredPaddingApiLess22)
                : UiUtilities.GetAttributePixelSize(Context, Resource.Attribute.dialogPreferredPadding);

            ShowEvent += (s, e) =>
            {
                IWindowManager windowManager = (context as AppCompatActivity).WindowManager;

                DisplayMetrics displayMetrics = new DisplayMetrics();
                windowManager.DefaultDisplay.GetMetrics(displayMetrics);

                WindowManagerLayoutParams layoutParameters = new WindowManagerLayoutParams();
                layoutParameters.CopyFrom(Window.Attributes);

                //Int32 maxDialogWidth = (Int32)(displayMetrics.WidthPixels * 0.9);
                //if (Window.DecorView.Width > maxDialogWidth)
                //{
                //    layoutParameters.Width = maxDialogWidth;
                //}

                Int32 maxDialogHeight = (Int32)(displayMetrics.HeightPixels * 0.9);
                if (Window.DecorView.Height > maxDialogHeight)
                {
                    layoutParameters.Height = maxDialogHeight;
                }

                Window.Attributes = layoutParameters;
            };

            _layout = View.Inflate(Context, Resource.Layout.customDialogLayout, null) as ViewGroup;
            _layout.SetPadding(_preferredPadding, _preferredPadding, _preferredPadding, _preferredPadding);

            SetView(_layout);
        }