Example #1
0
        private ScrollBar GetVerticalScrollBar()
        {
            // wire up events for the scrollbar
            var explorerTreeView = ExplorerTreeView;
            var scrollBar        = (explorerTreeView == null ? null : ExplorerUtility.FindFirstVerticalScrollBar(explorerTreeView));

            // Is cached scrollbar the same as the one in the visual tree?
            if (!ReferenceEquals(_vScrollBar, scrollBar))
            {
                if (_vScrollBar != null)
                {
                    UnhookScrollBarEvents(_vScrollBar);
                    _vScrollBar   = null;
                    _scrollViewer = null;
                }

                // wire up events for the scrollbar
                _vScrollBar = scrollBar;
                if (_vScrollBar != null)
                {
                    _vScrollBar.SizeChanged      += VScrollBar_SizeChanged;
                    _vScrollBar.IsVisibleChanged += VScrollBar_IsVisibleChanged;
                    _vScrollBar.Unloaded         += VScrollBar_Unloaded;
                }
            }

            return(_vScrollBar);
        }