예제 #1
0
        private void OnScrollTimerTick(object sender, EventArgs e)
        {
            ScrollViewer scrollViewer = GetScrollViewer();

            if (scrollViewer != null)
            {
                if (scrollSpeed < 0)
                {
                    scrollViewer.LineUp();
                }
                else if (scrollSpeed > 0)
                {
                    // if the last line is already visible, then we don't need to scroll any further.
                    bool scroll = true;
                    if (scrollViewer.VerticalOffset + 10 > scrollViewer.ScrollableHeight)
                    {
                        // This checks to see if the last row is really visible, and avoid a weird
                        // bouncing jump that happens if we keep calling LineDown without checking.
                        double      height  = scrollViewer.ActualHeight;
                        DataGridRow lastRow = this.GetRow(this.Items.Count - 1);
                        Point       pos     = lastRow.TransformToAncestor(scrollViewer).Transform(new Point(0, 0));
                        scroll = (pos.Y + lastRow.DesiredSize.Height > height + 16);
                    }
                    if (scroll)
                    {
                        scrollViewer.LineDown();
                    }
                }
            }
            if (scrollTimer != null)
            {
                scrollTimer.Interval = TimeSpan.FromMilliseconds(nextInterval);
            }
        }
예제 #2
0
        void ShowPopup(DataGridRow row)
        {
            stayDispatcherTimer.Stop();

            UIElement popupTarget = null;

            switch (this.Target)
            {
            case PopupPlacement.Window:
            {
                Window window = Window.GetWindow(row);
                if (window != null && window.WindowState == WindowState.Maximized || window.WindowState == WindowState.Minimized)
                {
                    this.PopupView.IsOpen = false;
                    return;
                }

                popupTarget = window;
            }
            break;

            case PopupPlacement.DataGrid:
            {
                popupTarget = this.DataGrid;
            }
            break;

            default:
                break;
            }

            this.PopupView.PlacementTarget = popupTarget;
            this.PopupView.DataContext     = row.DataContext;

            Point point = row.TransformToAncestor(popupTarget).Transform(new Point(0, 0));

            this.PopupView.VerticalOffset = point.Y;
            this.PopupView.IsOpen         = true;
        }