Since the event handler is manually attached you will need also to manually remove it from the object. However, we will take some time to investigate the observed behavior in the VisualizationLayer's code too.
As for avoiding the exception, you can use different approaches based on your application's requirements. I updated your project to demonstrated a possible implementation which you can use. Basically, I defined a Boolean property in the MapItemViewModel that tells if the item has a parent (is it attached somehow to the layer) or not. Then, I am using the property in the condition for raising the LocationChanged event. I made few changes in the following files to set the property when the SelectedThing
is changed and when the Things
collection is populated:
I commented the changed parts of the code. Please give the project a try and let me know if this approach works for you.
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Telerik Feedback Portal
and vote to affect the priority of the items