I have the following code:

if (cboxCategory.SelectedIndex == 1)
                cboxSubcategory.IsEnabled = true;

                XmlDataProvider agriculture = new XmlDataProvider();

                agriculture.Source = new Uri(@"Data\Lists\agriculture.xml", UriKind.Relative);
                agriculture.XPath = "/AGRICULTURE";
                System.Windows.Data.Binding binding = new Binding();
                binding.Source = agriculture;
                binding.XPath = "Category";

                cboxSubcategory.SetBinding(ItemsControl.ItemsSourceProperty, binding);

                cboxSubcategory.SelectedIndex = 0;

basically, I have two comboboxes and when an item from the first one is selected the second combobox is enabled, data from an XML file is loaded into it and the first item from the list should be selected... but it's not. The list is loaded correctly, but it remains on SelectedIndex -1.

Anybody knows what I'm doing wrong?

thank you.

Yes, its too complicated for the idea that you want. You cant treat the xml data like any other data that is used in c#. try something like this

DataSet dsSet = new DataSet();
            dsSet.ReadXml(Application.StartupPath + "\\agriculture.xml");
            comboBox1.DataSource = dsSet.Tables["agriculture"];
            comboBox1.DisplayMember = "Category";

Simple and quick to load.