title: how to display drawingvisual on canvas above child UIElements of Canvas defined in XAML
body: <p>So I have a drawingvisual Marker in VisualCollection visuals in a class deriving from canvas.</p>
  
  <pre><code>public class OverlayCanvas:Canvas
  {
      VisualCollection visuals;
  
      DrawingVisual MarkerVisual = new DrawingVisual();
  }
  </code></pre>
  
  <p>In the xaml I have a drag selection border defined that I wish to also be drawn.</p>
  
  <pre><code>             Components:OverlayCanvas 
                  &gt;
  
                  &lt;Border 
                      x:Name="dragSelectionBorder"
                      BorderBrush="White"
                      BorderThickness="0"
                      CornerRadius="1"
                      Visibility="Collapsed"
                      /&gt;
               &lt;/Components:OverlayCanvas&gt;
  </code></pre>
  
  <p>How do I make both display?</p>
  
  <p>Normally I would override these, but do I have to define all children of the canvas in xaml and add them to the VisualCollection?  If I just override the two methods then when render calls getvisualchild, it draws only the marker DrawingVisual but it will not get the items defined in the xaml.</p>
  
  <pre><code>protected override Visual GetVisualChild(int index)
  {
    return visuals[index];
  }
  protected override int VisualChildrenCount
  {
    get
    {
      return visuals.Count;
    }
  }
  </code></pre>
  
  <p>I thought perhaps that I could Panel.Children.Add but it requires a UIElement.   I then thought that perhaps the correct thing was to just Visual.AddVisualChild, so I ran this code on the set marker event in the Canvas.</p>
  
  <pre><code>    {
      MarkerVisual = new DrawingVisual();
      using (DrawingContext dc = MarkerVisual.RenderOpen())
      {
        dc.DrawLine(MarkerPen, new Point(MouseHorizontalPositionInPixels, YPositionForStartOfVerticalAxisLines),
          new Point(MouseHorizontalPositionInPixels, ActualHeight));
      }
      this.AddVisualChild(MarkerVisual);
  </code></pre>
  
  <p>However, in this situation, the UIelements defined in xaml in the canvas are displayed, but not the marker drawingvisual.</p>