0

I had a WPF app which drew some geometry on a Canvas. Today I needed to add a Region Of Interest (ROI) rectangle which I initially did using the same canvas just for debugging. The Mouse Event handlers are used to draw the rectangle . . .

     <Canvas Name="cnv"  Canvas.Top="0" Canvas.Left="0"  Margin="10,21,315,251"
      MouseDown="cnvMouseDown" MouseUp="cnvMouseUp" MouseMove="cnvMouseMove" />

... That worked OK so I decided to move the ROI rectangle code to a separate Canvas overlaying the original one so I could delete and redraw the rectangle without disturbing the other geometry on the first Canvas. ... so now I have this . . .

        <Canvas Name="cnv"  Canvas.Top="0" Canvas.Left="0" Margin="10,21,315,251"
     MouseDown="cnvMouseDown" MouseUp="cnvMouseUp" MouseMove="cnvMouseMove" />

        <Canvas Name="ROIcnv" Canvas.Top="0" Canvas.Left="0" Margin="10,21,315,251"
 MouseDown="ROIcnvMouseDown" MouseUp="ROIcnvMouseUp" MouseMove="ROIcnvMouseMove"/>

... but now NONE of the mouse event handlers for either Canvas get triggered when I click or move the mouse. Note that the only ones I care about are the ones on the second canvas, i.e., the ROIcnv... ones.

user316117
  • 7,971
  • 20
  • 83
  • 158
  • 1
    You'll have to set the Background property of the Canvas (e.g. to Transparent), otherwise it won't get any mouse input. – Clemens Dec 30 '15 at 22:13
  • BIngo! That was it! (what does having a color to do with receiving mouse events?) Thanks! – user316117 Dec 30 '15 at 22:17

0 Answers0