Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The reason is that, you set the Trigger's Property to <strong>Canvas.IsMouseOver</strong>, so it will fire when the Canvas is Mouser Over. But as you set the Trigger in the Path's Style, this will limited within the area of the Path.</p> <p>I know the IsMouseOver is a Property, but i want to use MouseEnter as an example. MouseEnter is a Routed Event, so when the mouse is hover the <strong>TextBlock</strong>, it will fire as Routed Event, the TextBlock's MouseEnter Event will fire, and maybe the TextBlock's IsMouseOver became true, not the Path and the Canvas. Because now the TextBlock's ZIndex is the highest.</p> <p>So, what we need to do is let the TextBlock's IsMouseOver don't change when it get hovered.</p> <p>We can set the TextBlock's <strong>IsHitTestVisible="False"</strong>;</p> <p>And the Code can be like this: I have tested this code, it works!</p> <pre><code>&lt;Canvas Background="Transparent"&gt; &lt;Path Name="PathNodeType" StrokeThickness="1"&gt; &lt;Path.Style&gt; &lt;Style TargetType="Path"&gt; &lt;Setter Property="Stroke" Value="Black" /&gt; &lt;Setter Property="Fill" Value="LightGray" /&gt; &lt;Style.Triggers&gt; &lt;Trigger Property="IsMouseOver" Value="True"&gt; &lt;Setter Property="Stroke" Value="Blue" /&gt; &lt;Setter Property="Fill" Value="LightBlue" /&gt; &lt;/Trigger&gt; &lt;/Style.Triggers&gt; &lt;/Style&gt; &lt;/Path.Style&gt; &lt;Path.Data&gt; &lt;PathGeometry&gt; &lt;PathGeometry.Figures&gt; &lt;PathFigureCollection&gt; &lt;PathFigure IsClosed="True" StartPoint="20,40"&gt; &lt;PathFigure.Segments&gt; &lt;PathSegmentCollection&gt; &lt;ArcSegment IsLargeArc="True" Point="50,40" RotationAngle="45" Size="10,10" SweepDirection="Clockwise" /&gt; &lt;LineSegment Point="50,60" /&gt; &lt;LineSegment Point="20,60" /&gt; &lt;/PathSegmentCollection&gt; &lt;/PathFigure.Segments&gt; &lt;/PathFigure&gt; &lt;/PathFigureCollection&gt; &lt;/PathGeometry.Figures&gt; &lt;/PathGeometry&gt; &lt;/Path.Data&gt; &lt;/Path&gt; &lt;TextBlock Margin="22,40,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" FontWeight="Bold" Text="AND" IsHitTestVisible="False" TextWrapping="Wrap" /&gt; &lt;/Canvas&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload