protected override void OnElementChanged(ElementChangedEventArgs <AnimatedNavigationPage> e)
        {
            if (_navigationStack == null)
            {
                _navigationStack = new NavigationStack(XForms.NativeParent);
                _navigationStack.Show();
                _navigationStack.SetAlignment(-1, -1);
                _navigationStack.SetWeight(1, 1);
                _navigationStack.Show();
                SetNativeView(_navigationStack);
            }

            if (e.OldElement != null)
            {
                var navigation = e.OldElement as INavigationPageController;
                navigation.PopRequested              -= OnPopRequested;
                navigation.PopToRootRequested        -= OnPopToRootRequested;
                navigation.PushRequested             -= OnPushRequested;
                navigation.RemovePageRequested       -= OnRemovePageRequested;
                navigation.InsertPageBeforeRequested -= OnInsertPageBeforeRequested;
            }

            if (e.NewElement != null)
            {
                var navigation = e.NewElement as INavigationPageController;
                navigation.PopRequested              += OnPopRequested;
                navigation.PopToRootRequested        += OnPopToRootRequested;
                navigation.PushRequested             += OnPushRequested;
                navigation.RemovePageRequested       += OnRemovePageRequested;
                navigation.InsertPageBeforeRequested += OnInsertPageBeforeRequested;
                _previousPage = e.NewElement.CurrentPage;
                _navigationStack.IsPreviousViewVisible = Element.IsPreviousPageVisible;
            }
            base.OnElementChanged(e);
        }
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         if (_navigationStack != null)
         {
             _navigationStack.Unrealize();
             _navigationStack = null;
         }
     }
     base.Dispose(disposing);
 }