WPF programming, telerik adds a method for user-defined straight lines and background color areas.

Telerik is a powerful WPF third-party control library. The relevant setting code examples given here apply to earlier versions of Telerik, and are only for reference in certain situations. Direct copy may report errors due to version issues.

 

1. Front desk resources:

    <Window.Resources>
        <Style x:Key="CustomGridLineStyle"
               TargetType="Line">
            <Setter Property="StrokeDashArray"
                    Value="1,1" />
        </Style>

    </Window.Resources>

2. Background code (custom straight line):

            CustomLine customLine = new CustomLine();
            customLine.Slope = 2.66;//斜率为0(默认),与X轴平行,为Infinity,与Y轴平行
            customLine.YIntercept = 33;//与Y轴的交点
            customLine.ElementStyle = (Style)this.FindResource("CustomGridLineStyle");
            customLine.Stroke = new SolidColorBrush(Colors.Green);//颜色
            customLine.StrokeThickness = 3;//线粗
            this.radChart.DefaultView.ChartArea.Annotations.Add(customLine);

 3. Background code (custom color area):

            MarkedZone redZone = new MarkedZone();
            redZone.StartY = 25;
            redZone.EndY = 35;
            redZone.Background = new SolidColorBrush(Color.FromArgb(255, 248, 109, 90));
            this.radChart.DefaultView.ChartArea.Annotations.Add(redZone);

 

Guess you like

Origin blog.csdn.net/qq_43307934/article/details/94875011