Answered Canvas Callback without Background Set

  • Wednesday, September 20, 2006 11:16 AM
     
     
    In the following example, the MouseDown callback works fine (example is from a browser app):
     
    <Canvas Height="500" Width="500" Background="Aqua" MouseDown="OnMouseDown"></Canvas>

    Removing the Background property seems to disable the MouseDown callback, the callback doesn't fire:

      <Canvas Height="500" Width="500" MouseDown="OnMouseDown"></Canvas>

    Is this expected?  Is there a fundemental reason why the background property would effect the mouse callbacks?

    (Using Windows SDK RC1 on XP)

    Thanks for any help!


All Replies

  • Wednesday, September 20, 2006 12:13 PM
     
     Answered
    I think some one has pointed out that WPF has a quite unique way of handling mouse event, it internally uses hit testing to determine which element is the source of the mouse event, so if you set the element's background into transparent, the hit testing will just go through it, so you have to  set the background of an element into non-transparent brush, so the mouse event can be detected and raised on it.

    Sheva