Tuesday, 27 August 2013

IsMouseOver not triggering

IsMouseOver not triggering

This question is related to another question that I just barely asked on
SO as well.
I have a Canvas with both a Path and a TextBlock in it.
<Canvas>
<Path Name="pathNodeType" StrokeThickness="1">
<Path.Style>
<Style>
<Setter Property="Path.Stroke" Value="Black" />
<Setter Property="Path.Fill" Value="LightGray" />
<Style.Triggers>
<Trigger Property="Canvas.IsMouseOver" Value="True">
<Setter Property="Path.Stroke" Value="Blue" />
<Setter Property="Path.Fill" Value="LightBlue" />
</Trigger>
</Style.Triggers>
</Style>
</Path.Style>
<Path.Data>
<PathGeometry>
<PathGeometry.Figures>
<PathFigureCollection>
<PathFigure IsClosed="True" StartPoint="20,40">
<PathFigure.Segments>
<PathSegmentCollection>
<ArcSegment Size="10,10"
RotationAngle="45" IsLargeArc="True"
SweepDirection="Clockwise"
Point="50,40" />
<LineSegment Point="50,60" />
<LineSegment Point="20,60" />
</PathSegmentCollection>
</PathFigure.Segments>
</PathFigure>
</PathFigureCollection>
</PathGeometry.Figures>
</PathGeometry>
</Path.Data>
</Path>
<TextBlock HorizontalAlignment="Left" Margin="22,40,0,0"
TextWrapping="Wrap" Text="AND" VerticalAlignment="Top"
FontWeight="Bold"/>
</Canvas>
The IsMouseOver property of the canvas triggers the path style as I expect
it to when the mouse pointer is over the drawn path. However, when the
mouse pointer is over the textblock (which is positioned right smack in
the middle of the drawn path) then the path style does not trigger as I
expect it to.
Why does it not trigger? The textblock resides within the canvas, so
technically speaking isn't the mouse pointer over the canvas as well?
Thanks in advance for any help on this.

No comments:

Post a Comment