【发布时间】:2013-08-27 18:44:13
【问题描述】:
这个问题与another question 有关,我也几乎没有问过这个问题。
我有一个 Canvas,里面有一个 Path 和一个 TextBlock。
<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>
当鼠标指针悬停在绘制的路径上时,画布的 IsMouseOver 属性会触发路径样式,正如我所期望的那样。但是,当鼠标指针位于文本块上(位于绘制路径的中间)时,路径样式不会像我预期的那样触发。
为什么不触发?文本块驻留在画布中,所以从技术上讲,鼠标指针不也是在画布上吗?
在此先感谢您提供任何帮助。
【问题讨论】: