Exemple #1
0
        private static void UpdateElementLocation(Popup popup)
        {
            var occlutedRect = InputPane.GetForCurrentView().OccludedRect;

            if (occlutedRect.Top > 0)
            {
                var element = FocusManager.GetFocusedElement() as FrameworkElement;
                if (element != null)
                {
                    SingleEvent.RegisterEvent(element,
                                              (e, h) => e.LostFocus += h,
                                              (e, h) => e.LostFocus -= h,
                                              delegate { UpdateElementLocation(popup); });

                    var point = element.TransformToVisual(Window.Current.Content).TransformPoint(new Point(0, 0));
                    if (point.X + element.ActualHeight + 100 > occlutedRect.Top)
                    {
                        var offset = (point.X + element.ActualHeight + 100) - occlutedRect.Top - (double)popup.Tag;
                        if (offset > 20)
                        {
                            popup.VerticalOffset -= offset;
                            popup.Tag             = (double)popup.Tag + offset;
                        }
                    }
                }
            }
        }