예제 #1
0
 public void SelectMarker(MapMarker mapMarker, bool keepPrev)
 {
     if (!keepPrev)
     {
         SelectedItems.Clear();
     }
     if (!SelectedItems.Contains(mapMarker.Data))
     {
         SelectedItems.Add(mapMarker.Data);
     }
 }
예제 #2
0
        private MapMarker CreateMarker(object sourceItem)
        {
            var template = ItemTemplateSelector != null
                ? ItemTemplateSelector.SelectTemplate(sourceItem, null) ?? ItemTemplate
                : ItemTemplate;

            if (template == null)
            {
                return(null);
            }

            var dataElement = template.LoadContent() as FrameworkElement;

            if (dataElement == null)
            {
                return(null);
            }

            var labelTemplate = _mapControl.ShowLabel ? (LabelTemplateSelector != null
                ? LabelTemplateSelector.SelectTemplate(sourceItem, null) ?? LabelTemplate
                : LabelTemplate) : null;

            var container = new MapMarkerContainer();

            container.SetValue(StyleProperty, MarkerContainerStyle);
            container.Content     = dataElement;
            container.DataContext = sourceItem;

            if (labelTemplate != null)
            {
                container.LabelContent = labelTemplate.LoadContent() as FrameworkElement;
            }

            var marker = new MapMarker(container);

            marker.MouseDown += (sender, args) => SelectMarker((MapMarker)sender,
                                                               Keyboard.IsKeyDown(Key.LeftShift) || (Keyboard.IsKeyDown(Key.RightShift) ||
                                                                                                     Keyboard.IsKeyDown(Key.LeftCtrl) || (Keyboard.IsKeyDown(Key.RightCtrl))));
            return(marker);
        }