Tech Off Post

Single Post Permalink

View Thread: I always get a black backgraound with DrawingContext in WPF
  • User profile image

    Thanks. This is progress. I can now move things around after clicking on them It is a bit odd that I can move an element by setting its Offset but it doesn't know what offset originally was. My code now sets the Offset property of the DrawingVisual when  created and reads it when clicked on. (BTW, the property has to be set by giving it "New Vector(10, 10)" or with whatever values. Otherwise you get "expression is a value and therefore cannot be the target of an assignment" when setting its x and y, even though they are read/write. Forgive for being confused.)

    Again, though, I may have not asked the right question. If I click on a rectangle, is there a way to get the 'System.Windows.Media.RectangleGeometry' out of the DrawingVisual? Can reach its Rect and pen or brush without removing them and recreating them? And I still haven't figured out how to remove objects.

    DrawingContext can draw a Ellipse, Geometry, GlyphRun, Line, and Rectangle, by using DrawDrawing, DrawEllipse, etc. This question goes for all of these.