Pre loader

AdornerLayerCanvas/add border around selected chart

Welcome to the SciChart Forums!

  • Please read our Question Asking Guidelines for how to format a good question
  • Some reputation is required to post answers. Get up-voted to avoid the spam filter!
  • We welcome community answers and upvotes. Every Q&A improves SciChart for everyone

WPF Forums | JavaScript Forums | Android Forums | iOS Forums



I have a number of charts in a dialog.
I would like to indicate which one is selected by the user, by e.g. adding a border around it.
So I thought the correct way was to use an Adorner.
But the SciChartSurface only has an AdornerLayerCanvas. It seems to be a bit different than the ususal Adoner pattern, but can it be used for this purpose, or is there a better way?
I cannot find any example either here or on google, but if you know of some, please let me know.


  • You must to post comments

Hi Bjarne,

Adding Adorners to the SciChartSurface should be no different than adding adorners to any other WPF control.

See the MSDN Article on Adorners

You can use some code like this to achieve it:

// Adorners must subclass the abstract base class Adorner.
public class SimpleCircleAdorner : Adorner
  // Be sure to call the base class constructor.
  public SimpleCircleAdorner(UIElement adornedElement)
    : base(adornedElement) 

  // A common way to implement an adorner's rendering behavior is to override the OnRender
  // method, which is called by the layout system as part of a rendering pass.
  protected override void OnRender(DrawingContext drawingContext)
    Rect adornedElementRect = new Rect(this.AdornedElement.DesiredSize);

    // Some arbitrary drawing implements.
    SolidColorBrush renderBrush = new SolidColorBrush(Colors.Green);
    renderBrush.Opacity = 0.2;
    Pen renderPen = new Pen(new SolidColorBrush(Colors.Navy), 1.5);
    double renderRadius = 5.0;

    // Draw a circle at each corner.
    drawingContext.DrawEllipse(renderBrush, renderPen, adornedElementRect.TopLeft, renderRadius, renderRadius);
    drawingContext.DrawEllipse(renderBrush, renderPen, adornedElementRect.TopRight, renderRadius, renderRadius);
    drawingContext.DrawEllipse(renderBrush, renderPen, adornedElementRect.BottomLeft, renderRadius, renderRadius);
    drawingContext.DrawEllipse(renderBrush, renderPen, adornedElementRect.BottomRight, renderRadius, renderRadius);

myAdornerLayer = AdornerLayer.GetAdornerLayer(sciChartSurface);
myAdornerLayer.Add(new SimpleCircleAdorner(sciChartSurface));

This should draw a box with grab-handles around the SciChartSurface. You can modify the Adorner.OnRender method to draw whatever you like.

Hope this helps!

Best regards,

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.