Joel
Joel

Reputation: 16664

Drawing using DrawingContext over elements on canvas

I'm drawing a selection box when I click and drag on my canvas object (which extends Canvas). I have overridden the OnRender method like so:

    protected override void OnRender(DrawingContext dc)
    {
        base.OnRender(dc);

        DrawGrid(dc);
        DrawSelector(dc);
    }

    private void DrawSelector(DrawingContext dc)
    {
        if (Selecting)
        {
            dc.DrawRectangle(new SolidColorBrush(Color.FromArgb(75, 0, 0, 255)), new Pen(Brushes.Blue, 1.5), SelectionRect);
        }
    }

But my selector is always drawn UNDER all the elements on the canvas. Does anyone know how I would draw my selector OVER all the UIElements on my canvas?

Thanks.

Upvotes: 2

Views: 3249

Answers (1)

Kent Boogaart
Kent Boogaart

Reputation: 178810

You can use an Adorner for this purpose.

Upvotes: 4

Related Questions