Example #1
0
        private void Init(DataTemplate template)
        {
            Random random = new Random(DateTime.Now.Millisecond);

            foreach (var info in _mapPointsInfo)
            {
                var mapPointViewModel = new MapPointViewModel(info)
                {
                    Count = _mapNameToCount[info.Name]
                };
                mapPointViewModel.Zoom          = Zoom;
                mapPointViewModel.MapPointColor = new SolidColorBrush(Color.FromRgb(
                                                                          (byte)random.Next(1, 255),
                                                                          (byte)random.Next(1, 255),
                                                                          (byte)random.Next(1, 255)));
                PlaceList.Add(mapPointViewModel);
                _mapNameToMapPoint.Add(mapPointViewModel.Name, mapPointViewModel);

                var mapCustomElement = new MapCustomElement()
                {
                    Content         = mapPointViewModel,
                    ContentTemplate = template,
                };

                _mapNameToMapElement.Add(info.Name, mapCustomElement);

                mapCustomElement.MouseLeftButtonDown += OnMapCustomElementClick;

                BindingOperations.SetBinding(mapCustomElement, MapCustomElement.LocationProperty,
                                             new Binding("Location")
                {
                    Source = mapPointViewModel
                });

                MapElements.Add(mapCustomElement);
            }
        }
Example #2
0
        private void Init(DataTemplate template)
        {
            Random random = new Random(DateTime.Now.Millisecond);

            foreach (var info in _mapPointsInfo)
            {
                var mapPointViewModel = new MapPointViewModel(info) { Count = _mapNameToCount[info.Name]};
                mapPointViewModel.Zoom = Zoom;
                mapPointViewModel.MapPointColor = new SolidColorBrush(Color.FromRgb(
                                                                                    (byte)random.Next(1, 255),
                                                                                    (byte)random.Next(1, 255),
                                                                                    (byte)random.Next(1, 255)));
                PlaceList.Add(mapPointViewModel);
                _mapNameToMapPoint.Add(mapPointViewModel.Name, mapPointViewModel);

                var mapCustomElement = new MapCustomElement()
                {
                    Content = mapPointViewModel,
                    ContentTemplate = template,
                };

                _mapNameToMapElement.Add(info.Name, mapCustomElement);

                mapCustomElement.MouseLeftButtonDown += OnMapCustomElementClick;

                BindingOperations.SetBinding(mapCustomElement, MapCustomElement.LocationProperty,
                    new Binding("Location") { Source = mapPointViewModel });

                MapElements.Add(mapCustomElement);
            }
        }