Inheritance: Windows.UI.Xaml.Controls.Primitives.SelectorItem, IListBoxItem
Beispiel #1
0
 async private void openFolder_Click(object sender, RoutedEventArgs e)
 {
     if (lbFolder.SelectedItem == null)
     {
         await new MessageDialog("请选择一个文件夹").ShowAsync();
     }
     else 
     {
         ListBoxItem item = lbFolder.SelectedItem as ListBoxItem;
         //获取文件夹内容
         StorageFolder folder = item.DataContext as StorageFolder;
         lbFolder.Items.Clear();
         foreach (StorageFolder folder1 in await folder.GetFoldersAsync())
         {
             ListBoxItem item1 = new ListBoxItem();
             item1.Content = "文件夹:" + folder1.Name;
             item1.DataContext = folder1;
             lbFolder.Items.Add(item1);
         }
         lbFile.Items.Clear();
         foreach (StorageFile file in await folder.GetFilesAsync())
         {
             ListBoxItem item2 = new ListBoxItem();
             item2.Content = "文件:" + file.Name;
             item2.DataContext = file;
             lbFolder.Items.Add(item2);
         }
     }
 }
Beispiel #2
0
        //Вывод списка слов каждого игрока
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            if (e.Parameter != null)
            {
                g = (Game)e.Parameter;

                TxtFirstPlayerName.Text = g.Player1.Name;
                TxtFirstPlayerName.Foreground = new SolidColorBrush(Colors.Black);
                TxtSecondtPlayerName.Text = g.Player2.Name;
                TxtSecondtPlayerName.Foreground = new SolidColorBrush(Colors.Black);

                foreach (string i in g.Player1.Words) //Слова первого игрока
                {
                    ListBoxItem item = new ListBoxItem();
                    item.HorizontalContentAlignment = HorizontalAlignment.Center;
                    item.VerticalContentAlignment = VerticalAlignment.Center;
                    item.Content = i.ToUpper();
                    item.FontSize = 50;
                    LstFirstPlayerWords.Items.Add(item);
                }

                foreach (string i in g.Player2.Words) //Слова второго игрока
                {
                    ListBoxItem item = new ListBoxItem();
                    item.HorizontalContentAlignment = HorizontalAlignment.Center;
                    item.VerticalContentAlignment = VerticalAlignment.Center;
                    item.Content = i.ToUpper();
                    item.FontSize = 50;
                    LstSecondPlayerWords.Items.Add(item);
                }
            }
        }
Beispiel #3
0
 private async void UpdateList(string data)
 {
     await itemListBox.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal,
     () =>
     {
         var item = new ListBoxItem() { Content = data };
         itemListBox.Items.Add(item);
     });
 }
        public MainPage()
        {
            this.InitializeComponent();
            //ggg
            _geolocator = new Geolocator();
            _locationIcon10m = new LocationIcon10m();
            _locationIcon100m = new LocationIcon100m();
            //end
            NavigationCacheMode = NavigationCacheMode.Enabled;
            filterCanvas.Visibility = Visibility.Collapsed;
            emergencyCanvas.Visibility = Visibility.Collapsed;
            bgpostCanvas.Visibility = Visibility.Collapsed;
            postCanvas.Visibility = Visibility.Collapsed;
            for (int i = 0; i < 12; i++)
            {
                checkbox[i] = true;
                postcheckbox[i] = false;
            }
            checkallcheckbox();
            getCurrentLocation();

            //Post construct
            for (int i = 0; i < 31; i++)
            {  
                dayItem[i] = new ListBoxItem();
                dayItem[i].Content = i+1;
                dayCombo.Items.Add(dayItem[i]);
            }
            DateTime curTime = DateTime.Now;
            switch (curTime.Month)
            {
                case 0:
                case 2:
                case 4:
                case 6:
                case 7:
                case 9:
                case 11: dayItem[28].Visibility = Visibility.Visible;
                    dayItem[29].Visibility = Visibility.Visible;
                    dayItem[30].Visibility = Visibility.Visible;
                    break;
                case 1: dayItem[28].Visibility = Visibility.Collapsed;
                    dayItem[29].Visibility = Visibility.Collapsed;
                    dayItem[30].Visibility = Visibility.Collapsed;
                    break;
                default: dayItem[28].Visibility = Visibility.Visible;
                    dayItem[29].Visibility = Visibility.Visible;
                    dayItem[30].Visibility = Visibility.Collapsed;                    
                    break;
            }

            //Post initial


        }
 /// <summary>
 /// Populates the page with content passed during navigation.  Any saved state is also
 /// provided when recreating a page from a prior session.
 /// </summary>
 /// <param name="navigationParameter">The parameter value passed to
 /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested.
 /// </param>
 /// <param name="pageState">A dictionary of state preserved by this page during an earlier
 /// session.  This will be null the first time a page is visited.</param>
 protected override void LoadState(Object navigationParameter, Dictionary<String, Object> pageState)
 {
     SubContinent[] subContinents = Calender2.Data.CityData.GetCityData();
     for (int i = 0; i < subContinents.Length; i++)
     {
         ListBoxItem item = new ListBoxItem();
         TextBlock textBlock = new TextBlock();
         item.Content = textBlock;
         textBlock.Text = subContinents[i]._Name;
         SubContinentList.Items.Add(item);
         SubContinentList.Visibility = Visibility.Visible;
     }
     this.pageTitle.Text = "Change City";
     itemDetailPage = navigationParameter as ItemDetailPage;
 }
Beispiel #6
0
        /// <summary>
        /// 在此页将要在 Frame 中显示时进行调用。
        /// </summary>
        /// <param name="e">描述如何访问此页的事件数据。Parameter
        /// 属性通常用于配置页。</param>
        async protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            System.Collections.ObjectModel.ObservableCollection<object> ItemList = new System.Collections.ObjectModel.ObservableCollection<object>();
            foreach (View s in Constants.ViewList)
            {
                ListBoxItem item = new ListBoxItem();
                item.Content = s;
                item.Name = s.ClassType.FullName;
                ItemList.Add(item);
            }
            lstViews.ItemsSource = ItemList;

            //get my user info
            var info = await UserInfoService.Instance.RequestMyUserInfo();
            imgHead.Source = new BitmapImage(new Uri(info.Result.Head_url));
            txtName.Text = info.Result.User_name;
        }
        private async void btnGetUICC_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                var modem = MobileBroadbandModem.GetDefault();
                MobileBroadbandModemConfiguration modemCfg = await modem.GetCurrentConfigurationAsync();
                MobileBroadbandUicc uicc = modemCfg.Uicc;
                if (uicc != null)
                {
                    StringBuilder sb = new StringBuilder();
                    sb.AppendLine("SIM Card ICCID:" + uicc.SimIccId);
                    
                    
                    MobileBroadbandUiccAppsResult appsResult = await uicc.GetUiccAppsAsync();
                    System.Collections.ObjectModel.ObservableCollection<object> AppList = new System.Collections.ObjectModel.ObservableCollection<object>();
                    foreach (var uiccApp in appsResult.UiccApps)
                    {
                        ListBoxItem item = new ListBoxItem();
                        item.Name = uiccApp.Kind.ToString();
                        item.Content = uiccApp;
                        AppList.Add(item);
                    }

                    listUiccApps.ItemsSource = AppList;
                    if (AppList.Count > 0)
                    {
                        listUiccApps.SelectedIndex = 0;
                    }
                    else
                    {
                        sb.AppendLine("No UICC app found.");
                    }

                    txtUICCInformation.Text = sb.ToString();
                }
            }
            catch (Exception ex)
            {
                rootPage.NotifyUser("Error:" + ex.Message, NotifyType.ErrorMessage);
            }
        }
Beispiel #8
0
       async  private void btGetFolder_Click(object sender, RoutedEventArgs e)
        {
            lbFolder.Items.Clear();
            StorageFolder localFolder = Windows.ApplicationModel.Package.Current.InstalledLocation;
            foreach (StorageFolder folder in await localFolder.GetFoldersAsync())
            {
                ListBoxItem item = new ListBoxItem();
                item.Content = "应用程序目录" + folder.Name;
                item.DataContext = folder;
                lbFolder.Items.Add(item);
            }
            lbFile.Items.Clear();
            foreach (StorageFile file in await localFolder.GetFilesAsync())
            {
                ListBoxItem item1 = new ListBoxItem();
                item1.Content = "文件" + file.Name;
                item1.DataContext = file;
                lbFolder.Items.Add(item1);
            }

        }
        private async void flipView_SelectionChanged_1(object sender, SelectionChangedEventArgs e)
        {
            tagsListBox.Items.Clear(); 
            // HACK - Come back and fix this shit
            if (this.flipView.SelectedItem == null)
                return; 

            // There is a bug which should be addressed here, but I'm not sure how to solve it. 
            // In the case that the flip view is changed, the video should stop playing. 
            
            var selectedItem = (VideoModel)this.flipView.SelectedItem;
            
            selectedVideoID = selectedItem.VideoId;
            pageTitle.Text = selectedItem.Title; 
            

            //tagsListBox.ItemsSource = selectedItem.Tags;
            foreach (string tag in selectedItem.Tags)
            {
                var lbi = new ListBoxItem();
                lbi.Content = "#" + tag;
                tagsListBox.Items.Add(lbi); 
            }

            try
            {
                var profileRequest = new ApiRequest("user/profile");
                profileRequest.Authenticated = true;
                profileRequest.Parameters.Add("userId", selectedItem.User.UserId.ToString());
                profileRequest.Parameters.Add("currentUserId", App.LoggedInUser.UserId.ToString());
                Profile responseProfile = await profileRequest.ExecuteAsync<Profile>();
                this.authorDisplayControl.DataContext = responseProfile.User;
            }
            catch (Exception ex)
            {

            }
        }
        /// <summary>
        /// Helper Method to Create UI inside the ListBox for adding Productwise order details
        /// like Quantity
        /// </summary>
        void CreateBillUI()
        {
            stkPnlContainer = new StackPanel();
            stkPnlContainer.Orientation = Orientation.Horizontal;
            stkPnlContainer.Width = lstContainer.Width;
            stkPnlContainer.Height = 50;

            cmbProducts = new ComboBox();
            cmbProducts.ItemsSource = Products;
            cmbProducts.Width = 150;
            cmbProducts.Height = 50;
            cmbProducts.DisplayMemberPath = "ProductName";
            cmbProducts.SelectedValuePath = "ProductID";
            //Register to the event to generate Product details
            cmbProducts.SelectionChanged += cmbProducts_SelectionChanged;
            stkPnlContainer.Children.Add(cmbProducts);

            txtUnitPrice = new TextBox();
            txtUnitPrice.Width = 150;
            txtUnitPrice.Height = 50;
            txtUnitPrice.IsEnabled = false;
            txtUnitPrice.Text = "000";
            stkPnlContainer.Children.Add(txtUnitPrice);

            txtQuantity = new TextBox();
            txtQuantity.Width = 150;
            txtQuantity.Height = 50;
            txtQuantity.Text = "000";
            //Register to the event to generate bill for a Product
            txtQuantity.LostFocus += txtQuantity_LostFocus;
            stkPnlContainer.Children.Add(txtQuantity);

            txtProductwiseBill = new TextBox();
            txtProductwiseBill.Width = 150;
            txtProductwiseBill.Height = 50;
            txtProductwiseBill.Text = "000";
            txtProductwiseBill.IsEnabled = false;
            stkPnlContainer.Children.Add(txtProductwiseBill);

            ListBoxItem lst = new ListBoxItem();
            lst.Content = stkPnlContainer;
            lstContainer.Items.Add(lst);
        }
Beispiel #11
0
        private void populateChannelList()
        {
          channels.Clear();

          List<RemoteButton> blist = ((App)(CPRemoteApp.App.Current)).deviceController.channelController.buttonScanner.getButtons();

          ListBoxItem item;
          ChannelList content;
          for (int i = 0; i < blist.Count; i++)
          {
            item = new ListBoxItem();
            content = new ChannelList(blist[i].getName(), i);
            content.deletePressed += channelButtonDeletePressed;
            content.editPressed += channelButtonEditPressed;
            item.Content = content;
            channels.Add(item);
          }
          item = new ListBoxItem();
          content = new ChannelList("Add New Channel", -1);
          item.Content = content;

          content.Changed += delegate
          {

            AddNewChannelPopup popup_content = new AddNewChannelPopup();
            Border border = new Border
            {
              Child = popup_content,
              Width = 840,
              Height = 280,
              Background = new SolidColorBrush(Colors.LightBlue),
              BorderBrush = new SolidColorBrush(Colors.Black),
              BorderThickness = new Thickness(4),
              Padding = new Thickness(20, 10, 20, 0)
            };

            popup_control = new Popup
            {
              Child = border,
              IsLightDismissEnabled = true
            };

            popup_control.Closed += add_channel_popup_Closed;

            border.Loaded += (loadedSender, loadedArgs) =>
            {
              popup_control.HorizontalOffset = (Window.Current.Bounds.Width - border.ActualWidth) / 2;
              popup_control.VerticalOffset = 100;
            };
            popup_content.setParentPopup(ref popup_control);
            popup_control.IsOpen = true;
          };

          channels.Add(item);
        }
 public void SetupMenuItem(ListBoxItem sender)
 {
     _menuItem = sender;
     _presenter.ReportLoaded();
 }
        private void SubContinentList_SelectionChanged_1(object sender, SelectionChangedEventArgs e)
        {
            int index = SubContinentList.SelectedIndex;

            if (index == -1)
            {
                return;
            }

            SubContinent[] subContinents = Calender2.Data.CityData.GetCityData();
            SubContinent subContinent = subContinents[index];
            ListBox listBoxToUse;
            ScrollViewer scrollerToUse;

            if (subContinent._stateOrCityList[0] is State)
            {
                listBoxToUse = StateList;
                scrollerToUse = StateScroller;
            }
            else
            {
                // Hide state list
                StateScroller.Visibility = Visibility.Collapsed;
                listBoxToUse = CityList;
                scrollerToUse = CityScroller;
            }
            listBoxToUse.Items.Clear();
            listBoxToUse.Tag = subContinent;

            foreach (StateOrCity stateOrCity in subContinent._stateOrCityList)
            {
                ListBoxItem item = new ListBoxItem();
                TextBlock textBlock = new TextBlock();
                item.Content = textBlock;
                textBlock.Text = stateOrCity._Name;
                listBoxToUse.Items.Add(item);
            }
            scrollerToUse.Visibility = Visibility.Visible;
        }
        /// <summary>
        /// Generated when an item in the listbox is tapped
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ListBoxItem_Tapped(object sender, TappedRoutedEventArgs e)
        {
            MenuFlyout menu = new MenuFlyout();
            MenuFlyoutItem markAsCompleted = new MenuFlyoutItem();
            ListBoxItem newTaskList = (ListBoxItem)sender;
            _lastSelectedListBox = newTaskList;
            if (((sender as ListBoxItem).Background as SolidColorBrush).Color == Colors.Green)
            {
                markAsCompleted.Text = "Mark as incomplete";
                markAsCompleted.Click += MenuMarkIncomplete;
            }
            else
            {
                markAsCompleted.Text = "Mark as completed";
                markAsCompleted.Click += MenuMarkAsCompleted;
            }
            MenuFlyoutItem menuRemove = new MenuFlyoutItem();
            menu.Items.Add(markAsCompleted);
            menuRemove.Text = "Remove";
            menuRemove.Click += MenuRemove;
            menu.Items.Add(menuRemove);
            menu.ShowAt((FrameworkElement)sender);
 
        }
        /// <summary>
        /// Once a website is inserted. the listview is filled with the tasks created by the user
        /// </summary>
        private async void FillList()
        {
            string response = await _webClient.GetStringAsync(new Uri(websiteURI.Text + "api/readTasks.php?userID=" + uidbox.Text));

            string[] tasks = response.Split(new string[] { "#ENDTASK#" }, StringSplitOptions.RemoveEmptyEntries);

            foreach (var task in tasks)
            {
                string[] row = task.Split(':');
                ListBoxItem newTaskList = new ListBoxItem();
                newTaskList.Name = row[0];
                newTaskList.Content = row[2];
                newTaskList.Width = Window.Current.Bounds.Width;
                newTaskList.Background = new SolidColorBrush(Colors.Transparent);
                if (row[1] == "1")
                {
                    newTaskList.Background = new SolidColorBrush(Colors.Green);
                }
                newTaskList.Tapped += ListBoxItem_Tapped;
                listView.Items.Add(newTaskList);
            }
        }
        public void ParseScores(string jsonArrayAsString)
        {
            int position = 1;

            JArray jsonArray = JArray.Parse(jsonArrayAsString);
            JToken jsonArray_Item = jsonArray.First;
            while (jsonArray_Item != null)
            {
                string username = jsonArray_Item.Value<string>("username");
                string value = jsonArray_Item.Value<string>("value");
                string time = jsonArray_Item.Value<string>("time");

                string usernamePlusNumber = position.ToString() + "." +  username;
                position++;
                int time_num, time_mins, time_secs;
                int.TryParse(time, out time_num);

                time_mins = time_num / 60;
                time_secs = time_num % 60;

                time = (time_mins.ToString().Length == 1 ? "0" + time_mins.ToString() : time_mins.ToString()) + ":" + (time_secs.ToString().Length == 1 ? "0" + time_secs.ToString() : time_secs.ToString());

                if (position > 11)
                    break;

                ListBoxItem item = new ListBoxItem();

                item.Content = usernamePlusNumber;
                item.FontSize = 20;
                item.FontFamily = new FontFamily("Segoe WP Semibold");
                item.Foreground = new SolidColorBrush(Colors.White);

                scores_name.Items.Add(item);

                item = new ListBoxItem();
                item.Content = value;
                item.FontSize = 20;
                item.FontFamily = new FontFamily("Segoe WP Semibold");
                item.Foreground = new SolidColorBrush(Colors.White);
                item.HorizontalContentAlignment = Windows.UI.Xaml.HorizontalAlignment.Center;

                scores_value.Items.Add(item);

                item = new ListBoxItem();
                item.Content = time;
                item.FontSize = 20;
                item.FontFamily = new FontFamily("Segoe WP Semibold");
                item.Foreground = new SolidColorBrush(Colors.White);
                item.HorizontalContentAlignment = Windows.UI.Xaml.HorizontalAlignment.Center;

                scores_time.Items.Add(item);

                //Be careful, you take the next from the current item, not from the JArray object.
                jsonArray_Item = jsonArray_Item.Next;
            }
        }
 private void SortChangedExecute(ListBoxItem item)
 {
     if (!(item?.Tag is TrackSort))
     {
         return;
     }
     var sort = (TrackSort)item.Tag;
     ChangeSort(sort);
 }
        private void SetLocation(ListBoxItem item, int index)
        {
            item.Visibility = Visibility.Visible;

            tempItems.Add(item);

            double t = index - SelectedIndex;
            double tk = k;
            double tr = r;
            double ts = s;
            double tz = z;
            int d = index - si;

            if (t < 1 && t > -1)
            {
                tk *= t;
                tr *= t;
                double tab = Math.Abs(t);
                ts += (1 - s) * (1 - tab);
                tz *= tab;
            }
            else if (t > 0)
            {
                tk += l * (t - 1);
            }
            else if (t < 0)
            {
                tk = -tk + (l * (t + 1));
                tr = -tr;
                d = si - index;
            }

            ((ScaleTransform)((TransformGroup)item.RenderTransform).Children[0]).ScaleX = ts;
            ((ScaleTransform)((TransformGroup)item.RenderTransform).Children[0]).ScaleY = ts;

            if (Orientation == Orientation.Horizontal)
                ((TranslateTransform)((TransformGroup)item.RenderTransform).Children[1]).X = tk;
            else
                ((TranslateTransform)((TransformGroup)item.RenderTransform).Children[1]).Y = tk;

            if (Orientation == Orientation.Horizontal)
                ((PlaneProjection)item.Projection).RotationY = tr;
            else
                ((PlaneProjection)item.Projection).RotationX = tr;
            ((PlaneProjection)item.Projection).LocalOffsetZ = tz;

            Canvas.SetZIndex(item, -d);
        }
        private async void AddPrivateEvent(DateTime date, String eventText, bool newEvent, PrivateEvent pEvent)
        {

            if (newEvent && _privateEvents.Contains(date, eventText))
            {
                Windows.UI.Popups.MessageDialog md = new Windows.UI.Popups.MessageDialog("Event  name already exists");
                await md.ShowAsync();
                return;
            }

            App app = (App)Application.Current;
            ListBoxItem item = new ListBoxItem();
            TextBlock textBlock = new TextBlock();
            textBlock.Text = eventText;
            item.Content = textBlock;
            PersonalEventList.Items.Add(item);
            PersonalEventListScroller.Visibility = Visibility.Visible;
            Separator.BorderThickness = new Thickness(0, 5, 0, 0);
            _personalEventList.Add(item);
            if (newEvent)
            {
                Debug.Assert(pEvent == null);
                pEvent = new PrivateEvent(date.ToString("d"), eventText);
                _privateEvents._privateEventList.Add(pEvent);
                _currentHighlightedDateItem.SetPrivateEvent(pEvent._eventText);
            }
            item.Tag = pEvent;
        }
 private void RemoveEventClick(object sender, RoutedEventArgs e)
 {
     if (_currentEventItem != null)
     {
         _privateEvents._privateEventList.Remove(_currentEventItem.Tag as PrivateEvent);
         _personalEventList.Remove(_currentEventItem);
         PersonalEventList.Items.Remove(_currentEventItem);
         _currentEventItem = null;
         RemoveEventButton.IsEnabled = false;
         _currentHighlightedDateItem.SetPrivateEvent(String.Empty);
     }
 }
 private void PersonalEventList_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     ListBox lb = sender as ListBox;
     _currentEventItem = lb.SelectedItem as ListBoxItem;
     RemoveEventButton.IsEnabled = true;
 }
        private void PopulateScenarios()
        {
            System.Collections.ObjectModel.ObservableCollection<object> ScenarioList = new System.Collections.ObjectModel.ObservableCollection<object>();
            int i = 0;

            // Populate the ListBox with the list of scenarios as defined in Constants.cs.
            foreach (Scenario s in scenarios)
            {
                ListBoxItem item = new ListBoxItem();
                s.Title = (++i).ToString() + ") " + s.Title;
                item.Content = s;
                item.Name = s.ClassType.FullName;
                ScenarioList.Add(item);
            }

            // Bind the ListBox to the scenario list.
            Scenarios.ItemsSource = ScenarioList;
            Scenarios.SelectedIndex = 0;
        }
 /// <summary>
 /// Generated when the "add task" button is clicked
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private async void button_Click(object sender, RoutedEventArgs e)
 {
     ListBoxItem lbi = new ListBoxItem();
     string value;
     textTask.Document.GetText(Windows.UI.Text.TextGetOptions.AdjustCrlf, out value);
     value = value.Trim();
     if (value != "")
     {
         string response = await _webClient.GetStringAsync(new Uri(websiteURI.Text + "api/saveTask.php?task=" + value + "&userID=" + uidbox.Text));
         lbi.Name = response;
         lbi.Content = value;
         lbi.Width = Window.Current.Bounds.Width;
         lbi.Tapped += ListBoxItem_Tapped;
         listView.Items.Add(lbi);
     }
     textTask.Document.SetText(Windows.UI.Text.TextSetOptions.None, "");
 }
        private void PopulateScenarios()
        {
            System.Collections.ObjectModel.ObservableCollection<object> ScenarioList = new System.Collections.ObjectModel.ObservableCollection<object>();
            int i = 0;

            // Populate the ListBox with the list of scenarios as defined in Constants.cs.
            foreach (Scenario s in scenarios)
            {
                ListBoxItem item = new ListBoxItem();
                s.Title = (++i).ToString() + ") " + s.Title;
                item.Content = s;
                item.Name = s.ClassType.FullName;
                ScenarioList.Add(item);
            }

            // Bind the ListBox to the scenario list.
            Scenarios.ItemsSource = ScenarioList;

            // Starting scenario is the first or based upon a previous selection.
            int startingScenarioIndex = -1;

            if (SuspensionManager.SessionState.ContainsKey("SelectedScenarioIndex"))
            {
                int selectedScenarioIndex = Convert.ToInt32(SuspensionManager.SessionState["SelectedScenarioIndex"]);
                startingScenarioIndex = selectedScenarioIndex;
           }

            Scenarios.SelectedIndex = startingScenarioIndex != -1 ? startingScenarioIndex : 0;
        }
        private void StateList_SelectionChanged_1(object sender, SelectionChangedEventArgs e)
        {
            int index = StateList.SelectedIndex;

            // ignore invalid index (caused by items.clear() below)
            if (index == -1)
            {
                return;
            }

            ListBox listBox = sender as ListBox;
            SubContinent subContinent = listBox.Tag as SubContinent;
            StateOrCity stateOrCity = subContinent._stateOrCityList[index];
            State state = stateOrCity as State;

            // StateList.Items.Clear();
            CityList.Items.Clear();
            CityList.Tag = state;
            foreach (City city in state._cities)
            {
                ListBoxItem item = new ListBoxItem();
                TextBlock textBlock = new TextBlock();
                item.Content = textBlock;
                textBlock.Text = city._Name;
                CityList.Items.Add(item);
                CityScroller.Visibility = Visibility.Visible;
            }
        }