Esempio n. 1
0
        private Task <bool> GetAppearedOrDisappearedTask(Page page)
        {
            TaskCompletionSource <bool> tcs = new TaskCompletionSource <bool> ();

            NavigationRenderer.ParentingViewController parentViewController = Platform.GetRenderer((VisualElement)page).ViewController.ParentViewController as NavigationRenderer.ParentingViewController;
            if (parentViewController == null)
            {
                throw new NotSupportedException("ParentingViewController parent could not be found. Please file a bug.");
            }
            EventHandler appearing    = (EventHandler)null;
            EventHandler disappearing = (EventHandler)null;

            appearing = (EventHandler)((s, e) =>
            {
                parentViewController.Appearing -= appearing;
                parentViewController.Disappearing -= disappearing;
                Device.BeginInvokeOnMainThread((Action)(() => tcs.SetResult(true)));
            });
            disappearing = (EventHandler)((s, e) =>
            {
                parentViewController.Appearing -= appearing;
                parentViewController.Disappearing -= disappearing;
                Device.BeginInvokeOnMainThread((Action)(() => tcs.SetResult(false)));
            });
            parentViewController.Appearing    += appearing;
            parentViewController.Disappearing += disappearing;
            return(tcs.Task);
        }
Esempio n. 2
0
 private void UpdateLeftBarButtonItem(NavigationRenderer.ParentingViewController containerController)
 {
     /*
      * Page child = containerController.Child;
      * Page page = Enumerable.LastOrDefault<Page> ((IEnumerable<Page>)((NavigationPage)this.Element).get_StackCopy ());
      * if (child != page && NavigationPage.GetHasBackButton (child) || this.parentMasterDetailPage == null)
      *      return;
      * if (!this.parentMasterDetailPage.ShouldShowToolbarButton ())
      * {
      *      containerController.NavigationItem.LeftBarButtonItem = (UIBarButtonItem)null;
      * }
      * else
      * {
      *      bool flag = this.parentMasterDetailPage.Master.Icon != null;
      *      if (flag)
      *      {
      *              try
      *              {
      *                      containerController.NavigationItem.LeftBarButtonItem = new UIBarButtonItem (new UIImage ((string)this.parentMasterDetailPage.Master.Icon), UIBarButtonItemStyle.Plain, (EventHandler)((o, e) => this.parentMasterDetailPage.IsPresented = !this.parentMasterDetailPage.IsPresented));
      *              }
      *              catch (Exception ex)
      *              {
      *                      flag = false;
      *              }
      *      }
      *      if (flag)
      *              return;
      *      containerController.NavigationItem.LeftBarButtonItem = new UIBarButtonItem (this.parentMasterDetailPage.Master.Title, UIBarButtonItemStyle.Plain, (EventHandler)((o, e) => this.parentMasterDetailPage.IsPresented = !this.parentMasterDetailPage.IsPresented));
      * }
      */
 }