Facebook
From Stained Ostrich, 9 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 463
  1.   static public void Showing(Page page, Windows.UI.ViewManagement.InputPane sender, Windows.UI.ViewManagement.InputPaneVisibilityEventArgs args)
  2.         {
  3.             const double extraHeightBuffer = 20.0;
  4.  
  5.             UIElement focused = FocusManager.GetFocusedElement() as UIElement;
  6.             if (null != focused)
  7.             {
  8.                 GeneralTransform gt = focused.TransformToVisual(page);
  9.                 Point focusedPoint = gt.TransformPoint(new Point(0, focused.RenderSize.Height - 1));
  10.                 double bottomOfFocused = focusedPoint.Y + extraHeightBuffer;
  11.                 double windowHeight = Window.Current.Bounds.Height;
  12.                 double topOfInputPane = windowHeight - args.OccludedRect.Height;
  13.                 if (bottomOfFocused > topOfInputPane)
  14.                 {
  15.                     var trans = new TranslateTransform();
  16.                     trans.Y = -(bottomOfFocused - topOfInputPane);
  17.                     page.RenderTransform = trans;
  18.                 }
  19.  
  20.                 args.EnsuredFocusedElementInView = true;
  21.             }
  22.         }