I have a suggestion though regarding databinding on VEMap ItemsSource. I think it would be nice to wrap the items data bound into VEPushPin much like Treeview vs treeviewItem or ScatterView vs ScatterviewItem. This way we don't have to bind to a VEPushPin
collection. I have experienced it a bit and it seems pretty straightforward, the only trick is how to map VEPushPin altitude, longitude, latitude properties.
I have tested with the following changes:
- register VEPushpin's Altitude, Latitude and Longitude DPs as "Attached" DPs,
- on my data item, I bind my alt/lat/lon properties to the VEPushPin attached properties
- override VEMap's GetContainerForItemOverride method in order to return VEPushPin as item container
- update RaiseViewChanged method on VEMap in order to call VEPushPin's UpdatePosition if the item Container is VEPushPin
( if ( o is VEPushPin || this.ItemContainerGenerator.ContainerFromItem(o) is VEPushPin) )
- override VEMap's PrepareContainerForItemOverride method in order to map the VEPushPin Latitude/Longitude properties to the item bound properties throught the Attached DPs:
if (element is VEPushPin && item is DependencyObject)
VEPushPin l_pushpin = (VEPushPin)element;
DependencyObject l_item = (DependencyObject)item;
l_pushpin.Latitude = (double)l_item.GetValue(VEPushPin.LatitudeProperty);
l_pushpin.Longitude = (double)l_item.GetValue(VEPushPin.LongitudeProperty);
The last thing here is to bind the VEPushPin lat/lon properties to the item (twoway binding).