SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, and now iOS Charting & Android Chart Components

Welcome to the SciChart Community Forums!

Please use the forums below to ask questions about SciChart. Take a moment to read our Question asking guidelines on how to ask a good question and our support policy. We also have a tag=SciChart on Stackoverflow.com where you can earn rep for your questions!

Please note: SciChart team will only answer questions from customers with active support subscriptions. Expired support questions will be ignored. If your support status shows incorrectly, contact us and we will be glad to help.

0
0

Hi,

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.

Thanks!

  • You must to post comments
0
0

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,
Andrew

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.