Ejemplo n.º 1
0
        /// <summary>Adds a back key handler for a given page. </summary>
        /// <param name="page">The page. </param>
        /// <param name="handler">The handler. </param>
        public void Add(MtPage page, Func <object, bool> handler)
        {
            if (!_isEventRegistered)
            {
#if WINDOWS_UAP
                SystemNavigationManager.GetForCurrentView().BackRequested += OnBackKeyPressed;
#else
                if (_hardwareButtonsType == null)
                {
                    _hardwareButtonsType = Type.GetType(
                        "Windows.Phone.UI.Input.HardwareButtons, " +
                        "Windows, Version=255.255.255.255, Culture=neutral, " +
                        "PublicKeyToken=null, ContentType=WindowsRuntime");
                }

                _registrationToken = EventUtilities.RegisterStaticEvent(_hardwareButtonsType, "BackPressed", OnBackKeyPressed);
#endif
                _isEventRegistered = true;
            }

            _handlers.Insert(0, new Tuple <MtPage, Func <object, bool> >(page, handler));
        }