February 6, 2004 .net

IanG on Rubber Band Selection Outlines in Avalon

Ian and I are writing an Avalon book for O’Reilly and Associates together, but he’s way out in front of me, writing cool stuff like how to get rubber band selection outlines in Avalon. He also starts with a wonderful history of the XOR technique we used to use in Windows and why we no longer need it. In fact, we don’t even need XOR in Windows Forms and GDI+ today, although lots of folks don’t know that.

The key trick in Ian’s implementation is putting a hidden <Rectangle> element into your XAML document so that when it’s time to do the rubber hand outline, you can show it, move it and resize it based on where the mouse is, hiding the Rectangle again when the mouse button is released. This lets Avalon take care of the drawing, making this technique a thing of beauty.