protected virtual void RebuildMarkers(bool shouldReleaseMarkers)
        {
            if (markerGenerator == null)
            {
                return;
            }

            if (shouldReleaseMarkers)
            {
                foreach (FrameworkElement item in itemsPanel.Children)
                {
                    var enumerator = item.GetLocalValueEnumerator();
                    while (enumerator.MoveNext())
                    {
                        item.ClearValue(enumerator.Current.Property);
                    }

                    descriptor.RemoveValueChanged(item, OnMarkerViewportBoundsChanged);
                    markerGenerator.ReleaseMarker(item);
                }
            }

            itemsPanel.Children.Clear();

            if (dataSource == null)
            {
                return;
            }

            IndividualArrangePanel specialPanel = itemsPanel as IndividualArrangePanel;

            if (specialPanel != null)
            {
                specialPanel.BeginBatchAdd();
            }

            foreach (object item in dataSource)
            {
                var marker = CreateMarker(item);
                itemsPanel.Children.Add(marker);
            }

            if (specialPanel != null)
            {
                specialPanel.EndBatchAdd();
            }

            RecalculateViewportBounds();
        }
        protected virtual void DrawAllMarkers(bool reuseExisting, bool continueAfterDataPrepaired)
        {
            if (!IsReadyToDrawMarkers())
            {
                return;
            }

            var dataSource = DataSource;

            dataSource.Environment = new DataSourceEnvironment {
                Plotter = this.Plotter, FirstDraw = true
            };

            if (!continueAfterDataPrepaired)
            {
                dataSource.PrepairData(getDataAsyncronously);
                if (getDataAsyncronously)
                {
                    LongOperationsIndicator.BeginLongOperation(this);
                    return;
                }
            }

            CurrentItemsPanel.Children.Clear();

            BuildCommonBindings();

            startIndex = 0;
            lastIndex  = startIndex;

            IndividualArrangePanel panel = CurrentItemsPanel as IndividualArrangePanel;

            if (panel != null)
            {
                panel.BeginBatchAdd();
            }

            ViewportHostPanel viewportPanel = CurrentItemsPanel as ViewportHostPanel;

            if (viewportPanel != null)
            {
                viewportPanel.OverallViewportBounds = DataRect.Empty;
            }

            foreach (var dataItem in dataSource.GetData())
            {
                CreateAndAddMarker(dataItem, lastIndex);
                lastIndex++;

                if (showMarkersConsequently && lastIndex % 100 == 0)
                {
                    // make dispatcher execute all operations in its queue;
                    // so that markers will appear on the screen step-by-step,
                    // making application more responsive.

                    // This line is dangerous, it causes WI 1677
                    // Dispatcher.Invoke(() => { }, DispatcherPriority.Background);
                }
            }
            if (panel != null)
            {
                panel.EndBatchAdd();
            }

            int len = CurrentItemsPanel.Children.Count;

            if (lastIndex < len)
            {
                for (int i = lastIndex; i < len; i++)
                {
                    UIElement element = CurrentItemsPanel.Children[i];
                    element.Visibility = Visibility.Collapsed;
                }
            }

            LongOperationsIndicator.EndLongOperation(this);
        }