Exemple #1
0
        public override DataTemplate SelectTemplate(object item, DependencyObject container)
        {
            Window mainWindow = Application.Current.MainWindow;

            LocationModel loc = item as LocationModel;

            if (loc == null || loc.AlternateItem)
            {
                return(Template1);
            }

            return(Template2);
        }
Exemple #2
0
        public void InitData()
        {
            ObservableCollection <LocationModel> newLocations = new ObservableCollection <LocationModel>();

            double centerLat   = 38.9444195081574;
            double centerLong  = -77.0630161230201;
            double spacingLat  = 0.002;
            double spacingLong = 0.0015;

            bool currentAlternate = false;
            int  currentGroup     = 1;

            int size = 5;

            for (int i = -size; i < size; i++)
            {
                currentAlternate = !currentAlternate;
                for (int j = -size; j < size; j++)
                {
                    LocationModel loc = new LocationModel(centerLat + i * spacingLat, centerLong + j * spacingLong, 0, i.ToString() + ", " + j.ToString());
                    loc.AlternateItem = currentAlternate;
                    currentAlternate  = !currentAlternate;
                    loc.GroupNumber   = currentGroup;

                    newLocations.Add(loc);

                    currentGroup++;
                    if (currentGroup > 4)
                    {
                        currentGroup = 1;
                    }
                }
            }
            _locations = newLocations;
            NotifyPropertyChanged("Locations");
        }