Пример #1
0
        private void OnPopupInitializing(object sender, EventArgs e)
        {
            Func <GestureRecognizer> factory = delegate
            {
                var closeOnTap = new TapGestureRecognizer();

                var cmd = new Command(obj =>
                {
                    var view = obj as View;

                    if (view == null)
                    {
                        return;
                    }

                    var evt = PopupTappedEventArgs.Create(this, view);

                    OnPropertyTapped(evt);
                });

                closeOnTap.Command = cmd;
                return(closeOnTap);
            };

            TapGestureRecognizerVisitor.Visit(_popupView, factory);
        }
        /// <summary>
        /// Instantiate a new <see cref="PopupTappedEventArgs"/>
        /// </summary>
        /// <param name="popup">The popup that was tapped</param>
        /// <param name="view">The view that was tapped</param>
        /// <returns></returns>
        public static PopupTappedEventArgs Create(Popup popup, View view)
        {
            PopupSectionType housingSectionType;

            var parentView = view.FindParent(ve =>
            {
                var parentSectionType = ve.GetValue(Popup.SectionTypeProperty);
                var currentSection    = (PopupSectionType)parentSectionType;

                return(currentSection == PopupSectionType.Body ||
                       currentSection == PopupSectionType.Footer ||
                       currentSection == PopupSectionType.Header);
            });


            if (parentView == null)
            {
                housingSectionType = PopupSectionType.Backdrop;
            }
            else
            {
                housingSectionType = (PopupSectionType)parentView.GetValue(Popup.SectionTypeProperty);
            }


            var controlType = (PopupSectionType)view.GetValue(Popup.SectionTypeProperty);
            var evt         = new PopupTappedEventArgs
            {
                Popup         = popup,
                ControlTapped = view,
                IsUserControl = controlType == PopupSectionType.NotSet,
                Section       = housingSectionType
            };

            return(evt);
        }
Пример #3
0
 protected virtual void OnPropertyTapped(PopupTappedEventArgs e)
 {
     Tapped?.Invoke(this, e);
 }