English

How To: Disable mouse events on Graphic features

Summary

By default, user interface (UI) elements in a Silverlight application are able to report mouse events. This may inhibit the ability to interact with components that overlap, such as Graphics layers in the ArcGIS API for Microsoft Silverlight/WPF. In general, UI elements allow mouse events to be disabled by setting the IsHitTestVisible property to false. However, Graphics layers and Graphic components are not UI elements, so this property is not available. Instead, a custom control template can be used to configure the IsHitTestVisible property on the geometry of the symbol used to render the Graphic. Instructions provided describe how to disable mouse events on Graphic features.

Procedure

In the XAML page, modify the existing symbol markup to define a control template. In this example, a fill symbol is used:

Code:

<esriSymbols:SimpleFillSymbol x:Name="DefaultFillSymbol" Fill="#66FF0000"
BorderBrush="Red" BorderThickness="1" >
<esriSymbols:SimpleFillSymbol.ControlTemplate>
<ControlTemplate>
<Path x:Name="Element"
IsHitTestVisible="False"
Fill="{Binding Symbol.Fill}"
Stroke="{Binding Symbol.BorderBrush}"
StrokeThickness="{Binding Symbol.BorderThickness}"/>
</ControlTemplate>
</esriSymbols:SimpleFillSymbol.ControlTemplate>
</esriSymbols:SimpleFillSymbol>

Note:
The IsHitTestVisible property is set to false. Any polygon Graphic features rendered in a Graphics layer using this symbol will not respond to mouse events. This enables interaction with graphics in another layer below these polygon Graphic features.