I'm creating a WPF application using the MVVM framework and I've hit a problem I can't solve. The application has a main window that displays a user control containing a map control with two Graphic layers, XAML below.
<esri:Map x:Name="map" IsLogoVisible="False" Background="White" WrapAround="True" MaximumResolution="2.5"
Height="{Binding ElementName=dckPnl_Map, Path=ActualHeight}"
Width="{Binding ElementName=dckPnl_Map, Path=ActualWidth}"
Extent="-401169.043457629, 6536918.47363432, -398878.321265893, 6538542.76048561"
local:MapHelpers.Extent="{Binding MapExtent}">
<!--<esri:AcceleratedDisplayLayers>-->
<esri:ArcGISLocalTiledLayer ID="OSStreetView" Path="./MapTiles/OsStreetView2013_18_11/v101/Layers/" />
<!--</esri:AcceleratedDisplayLayers>-->
<esri:GraphicsLayer ID="GPSLayer" x:Name="gpsLayer" IsHitTestVisible="True" RendererTakesPrecedence="True"
GraphicsSource="{Binding VehicleLocations, Source={StaticResource RTControlViewModel}}">
<esri:GraphicsLayer.Renderer>
<esri:SimpleRenderer Symbol="{StaticResource esriMarker}" />
</esri:GraphicsLayer.Renderer>
<esri:GraphicsLayer.MapTip>
<Border Padding="4,2" Background="Black">
<StackPanel>
<TextBlock Text="{Binding [Description]}" Foreground="White"/>
</StackPanel>
</Border>
</esri:GraphicsLayer.MapTip>
</esri:GraphicsLayer>
<!--<esri:GraphicsLayer ID="MarkerLayer" x:Name="markerLayer" IsHitTestVisible="True" RendererTakesPrecedence="True"
GraphicsSource="{Binding EditableLocations, Source={StaticResource RTControlViewModel}}">
<esri:GraphicsLayer.Renderer>
<esri:SimpleRenderer Symbol="{StaticResource esriMarker}" />
</esri:GraphicsLayer.Renderer>
<esri:GraphicsLayer.MapTip>
<Border Padding="4,2" Background="Black">
<StackPanel>
<TextBlock Foreground="White" Text="{Binding [Description]}"/>
</StackPanel>
</Border>
</esri:GraphicsLayer.MapTip>
</esri:GraphicsLayer>-->
<i:Interaction.Triggers>
<i:EventTrigger EventName="TouchDown">
<cmd:EventToCommand Command="{Binding TapLocation}" PassEventArgsToCommand="True"/>
</i:EventTrigger>
<i:EventTrigger EventName="MouseClick">
<cmd:EventToCommand Command="{Binding ClickLocation}" PassEventArgsToCommand="True"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</esri:Map>
I have just added the second GraphicsLayer after having just one, bound to a point data source, which I didn't have any problems with. Now, when I display the control for the first time everything works as expected, when I then display the control for a second time I get the the following error.Set property 'ESRI.ArcGIS.Client.GraphicsLayer.GraphicsSource' threw an exception. The inner exception has the following message.Specified argument was out of the range of valid values. Parameter name: Graphic is already associated with another layer.I'm saving my view models in memory and trying to reuse them for each instance of the controls. Does anyone have an idea what might be going wrong?ThanksAl