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:
当我单击并拖动我的画布对象(扩展Canvas)时,我正在绘制一个选择框。我已经覆盖了OnRender方法,如下所示:
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?
但是我的选择器总是在画布上的所有元素下绘制。有谁知道如何在我画布上的所有UIElements中绘制我的选择器?
Thanks.
1 个解决方案
#1
You can use an Adorner
for this purpose.
您可以使用Adorner来实现此目的。