Drawing a FrameworkElement within another FrameworkElement

Posted by Carlo on Stack Overflow See other posts from Stack Overflow or by Carlo
Published on 2010-03-31T21:03:59Z Indexed on 2010/03/31 23:03 UTC
Read the original article Hit count: 657

Filed under:
|

Hello I have this code:

public class VisualCue : FrameworkElement
 {
  public List<Indicator> Indicators { get; set; }

  public VisualCue()
  {
   this.Indicators = new List<Indicator>();
  }

  protected override int VisualChildrenCount
  {
   get
   {
    return this.Indicators.Count;
   }
  }

  protected override Visual GetVisualChild(int index)
  {
   return this.Indicators[index];
  }
 }

 public class Indicator : FrameworkElement
 {
  protected override void OnRender(DrawingContext context)
  {
   context.DrawEllipse(Brushes.Red, new Pen(Brushes.Black, 2), new Point(0, 0), 10, 10);

   base.OnRender(context);
  }
 }

And in XAML:

<local:VisualCue x:Name="visualCue">
 <local:VisualCue.Indicators>
  <local:Indicator />
 </local:VisualCue.Indicators>
</local:VisualCue>

But the indicator doesn't get drawn. What am I missing?

© Stack Overflow or respective owner

Related posts about wpf

Related posts about drawing