Quantcast
Channel: Visual C# forum
Viewing all articles
Browse latest Browse all 31927

need help with some coding please

$
0
0

hello to all

what I am trying to do is setting the selecteditem of a combobox to an item that is in a XML setting file.

I got 3 comboboxes  country, states, city

I populate this comboboxes from another XML file with all the countries states and cities.

the way I do it is I read the settings file and insert all data data in a class

mySettingsLocations = await MainSettings1.initialize<DefaultCountry>("mySettings.xml"); 

mySettingLocations = await MainSettings1.initialize<DefaultCountry>("mySettings.xml");

then I read the countries states and cities into a class and set the itemsource of the comboboxes the following way

LocationInfo locations = new LocationInfo();
locations = await locations.initialize("ms-appx:///CountryList.xml");

now I am able to set the selecteditem of the country combobox this way with a Linq query this way

IEnumerable<Country> selCountry = from scountry in locations.Countries where scountry.Name == mySettingLocations.Name select scountry;
CountryList.SelectedItem = selCountry.First();

I need to do the same for the states and city, for some reason I cannot extract the state and the city from the mySettingLocations class and set the selected item of the state and city combobox.

the mySettings XML looks like that

<?xml version="1.0"?><DefaultCountry xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><Name>Afghanistan</Name><City>Airdrie1</City><State>Badakhshan</State><SearchHistory>true</SearchHistory><Temprature>true</Temprature><DistanceUnit>true</DistanceUnit><CurrentView>Road</CurrentView><ShowZoomControls>true</ShowZoomControls></DefaultCountry>
Thank you


Viewing all articles
Browse latest Browse all 31927

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>