Пример #1
0
        /// <summary>
        /// When overridden in a derived class, is invoked whenever application code or internal
        /// processes call <see cref="FrameworkElement.ApplyTemplate"/>.
        /// </summary>
        public override void OnApplyTemplate()
        {
            _horizontalMajorLinesRenderer = null;
            _horizontalMinorLinesRenderer = null;
            _verticalMajorLinesRenderer = null;
            _verticalMinorLinesRenderer = null;

            base.OnApplyTemplate();
            var horizontalMajorLinesPath = GetTemplateChild("PART_HorizontalMajorLines") as Path;
            var horizontalMinorLinesPath = GetTemplateChild("PART_HorizontalMinorLines") as Path;
            var verticalMajorLinesPath = GetTemplateChild("PART_VerticalMajorLines") as Path;
            var verticalMinorLinesPath = GetTemplateChild("PART_VerticalMinorLines") as Path;

            if (horizontalMajorLinesPath != null)
                _horizontalMajorLinesRenderer = new PathRenderer(horizontalMajorLinesPath);

            if (horizontalMinorLinesPath != null)
                _horizontalMinorLinesRenderer = new PathRenderer(horizontalMinorLinesPath);

            if (verticalMajorLinesPath != null)
                _verticalMajorLinesRenderer = new PathRenderer(verticalMajorLinesPath);

            if (verticalMinorLinesPath != null)
                _verticalMinorLinesRenderer = new PathRenderer(verticalMinorLinesPath);

            Invalidate();
        }
Пример #2
0
        /// <inheritdoc/>
        public override void OnApplyTemplate()
        {
            _lineRenderer = null;
            _areaRenderer = null;

            base.OnApplyTemplate();

            _linePath = GetTemplateChild("PART_Line") as Path ?? new Path { Style = LineStyle };
            _areaPath = GetTemplateChild("PART_Area") as Path ?? new Path { Style = AreaStyle };

            _lineRenderer = new PathRenderer(_linePath);
            _areaRenderer = new PathRenderer(_areaPath);

            Invalidate();
        }