How To: Disable mouse events on Graphic features


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.


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


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

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.