Problem with mouse event on a user control (wpf).

Posted by csciguy on Stack Overflow See other posts from Stack Overflow or by csciguy
Published on 2010-04-23T21:12:49Z Indexed on 2010/04/23 21:13 UTC
Read the original article Hit count: 209

Filed under:
|
|

All,

I have a user control, defined as follows.

<UserControl x:Class="IDOView.AnimatedCharacter"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
         xmlns:local="clr-namespace:IDOView"
         mc:Ignorable="d"
         Background="Transparent"
         >
    <Image  Name="displayImage" Height="Auto" Width="Auto" Stretch="Fill" IsHitTestVisible="True"/>

The control is added to a main page twice, as follows.

<local:customControl x:Name="A1" Height="259" Width="197" DisplayImage="circle.png" Canvas.Left="-279" Canvas.Top="-56" MouseLeftButtonUp="DoA1">

<local:customControl x:Name="A1" Height="259" Width="197" DisplayImage="square.png" Canvas.Left="-209" Canvas.Top="-56" MouseLeftButtonUp="DoA2">

Essentially, about half of the circle is behind the square.

I need the square image in this case to pass through events to the circle behind it. The square has an element cut out of it (transparent). What is happening now is that the circle event only registers if I click on the region that is not covered by the square. Surely there has to be a way to bubble this event, or click-through?

© Stack Overflow or respective owner

Related posts about wpf

Related posts about c#