Page 1 of 1

WPF Colorline drawing priority

Posted: Mon Jun 15, 2015 10:48 am
by 9535497
Hi Steema,
I'm having a problem to draw colorline behind series, anotations, etc. in my WPF .NET application.
I'm using these Colorlines as an tolerance limits for charts in steel mill visualization application.
Drawbehind = true property is used but Lines are always on top though.
Is there a way to fix it?
Thank you for your help.

Branislav Baran

Re: WPF Colorline drawing priority

Posted: Tue Jun 16, 2015 9:24 am
by Christopher
Hello Branislav,

Unfortunately the Drawbehind is non-functional in WPF as the tool uses an AdornerLayer to do its drawing, and this layer is always drawn before all others.

However, this behaviour can be overridden using a very simple derivative of the ColorLine class, e.g.

Code: Select all

  public class MyColorLine : ColorLine
  {
    public MyColorLine(Chart c)
      : base(c) { }

    public MyColorLine()
      : this(null) { }

    protected override void ChartEvent(EventArgs e)
    {
      if ((iAxis != null) &&
       ((e is BeforeDrawSeriesEventArgs) || (e is AfterDrawEventArgs)))
      {
        Chart.Graphics3D.Pen = Pen;

        DrawColorLine(Chart.Graphics3D, e is BeforeDrawSeriesEventArgs);
      }
    }
  }
And then used like this:

Code: Select all

    private void InitializeChart()
    {
      Steema.TeeChart.WPF.Styles.Line line = new Steema.TeeChart.WPF.Styles.Line(tChart1.Chart);
      tChart1.Aspect.View3D = false;
      line.LinePen.Width = 3;
      line.FillSampleValues();

      MyColorLine tool = new MyColorLine(tChart1.Chart);
      tool.Axis = tChart1.Axes.Bottom;
      tool.Value = 5;
      tool.Pen.Color = Colors.LimeGreen;
      tool.Pen.Width = 2;
      tool.DrawBehind = true;
    }

Re: WPF Colorline drawing priority

Posted: Wed Jun 17, 2015 9:31 am
by 9535497
Thank you Christopher,
it works fine!

Branislav Baran