I am not sure if this is a bug or not, but I am getting strange behavior with some events.
I have a StackPanel. Inside of the StackPanel are a number of Grids. Each Grid is one row high and two columns wide. The first column contains a graphic, and the second column contains text, like this:
(img) Label 1
(img) Label 2
etc.
(I could in theory use StackPanels instead of Grids, but I have decided to use Grids).
The XAML is:
<Grid x:Name="LayoutRoot" MouseLeftButtonDown="LayoutRoot_MouseLeftButtonDown" Height="20" Width="250">
<Grid.RowDefinitions>
<RowDefinition />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="20" />
<ColumnDefinition Width="5" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Rectangle Height="5" Width="20" Fill="Black" Grid.Column="0" Grid.Row="0" x:Name="Rect"></Rectangle>
<TextBlock Text="" Grid.Column="2" Grid.Row="0" x:Name="txtLabel"></TextBlock>
</Grid> A user clicks on any of the text or images, triggering further events.
Here's the problem
Let's say there are three grids: 1, 2, 3.
A user clicks on the top most grid (#1).
But in the MouseLeftButtonDown handler, the value of e.OriginalSource says that the click originated from grid #3.
Clearly this causes all sorts of unusual behavior. I have successfully reproduced this several times, but have yet to understand what is causing this to occur. Any help would be greatly appreciated.