c# - How to find draw on System.Windows.Controls.*? -
i'm digging in wpf application written in c#.
need draw selection rectangle, 1 use select more 1 item (like files in folder).
have few objects, of types system.windows.controls.control, system.windows.controls.contentcontrol , system.windows.frameworkelement.
assume, need override event onpaint, ondraw or redraw/repaint.
can use object draw rectangle , how?
wpf , winforms different aspect. in winforms can override onpaint
draw directly drawing context using graphics
object in event handler.
in wpf, there onrender
method, seemingly behaves onpaint:
protected override void onrender(drawingcontext dc) { solidcolorbrush mysolidcolorbrush = new solidcolorbrush(); mysolidcolorbrush.color = colors.limegreen; pen mypen = new pen(brushes.blue, 10); rect myrect = new rect(0, 0, 500, 500); dc.drawrectangle(mysolidcolorbrush, mypen, myrect); }
however, in wpf every visual element object, cannot draw directly anything. "drawing" methods of drawingcontext
do, inserting objects visual tree, rendered later along other elements.
using onrender
not best idea, , has really bad performance comparing fast graphics
operations. in wpf better use custom controls or templates instead.
Comments
Post a Comment