示例#1
0
        /// <summary>
        /// creates a new tab when a item from the CBox is selected
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void CbCountry_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            Country selected;

            try
            {
                selected = (Country)CbCountry.SelectedItem;

                if (selected == null || CbCountry.SelectedIndex == 0)
                {
                    return;
                }

                if (!network)
                {
                    selected = dataService.QueryCountry(selected.Alpha3Code);
                }

                //creates the UserControl
                var newTab = new ShowCountryDetails(selected);

                //adds the selected item name(country) and the usercontrol page to the viewModel to be presented in the tab
                CountryTab tab = new CountryTab(selected.Name, newTab);

                CountryMainViewModel.AddTab(tab);

                CountryTabs.SelectedItem = tab;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\n" + ex.StackTrace);
            }
        }
示例#2
0
 public CountryTab(string tabName, UserControl newTab)
 {
     TabName = tabName;
     Window  = (ShowCountryDetails)newTab;
 }