Пример #1
0
            private void ScrollToBottom(bool mandatory)
            {
                ScrollViewer sv = VisualSearch.FindVisualChild <ScrollViewer>(listBox);

                if (mandatory || Math.Abs(sv.VerticalOffset - sv.ScrollableHeight) < 5)
                {
                    sv.ScrollToBottom();
                }
            }
Пример #2
0
        void ScrollToIndex(LogTabData tab, int index)
        {
            var item = VisualSearch.FindVisualChild <ListView>(logTabControl, view => view.DataContext == tab);

            item.SelectedIndex = index;

            var    vsp          = VisualSearch.FindVisualChild <ScrollViewer>(item);
            double scrollHeight = vsp.ScrollableHeight;

            double offset = scrollHeight * index / item.Items.Count + vsp.ViewportHeight / 2;

            vsp.ScrollToVerticalOffset(offset);
        }