1
得到這個錯誤Items collection must be empty before using ItemsSource.
無效操作異常是未處理
這個錯誤是在這一行中發現:
BuildstreamComboBox.ItemsSource = dz;
代碼:
public void PopulatebuildstreamFromXMLFile()
{
if (BuildmachineComboBox.SelectedIndex == 0)
{
ds3.Clear();
ds3.ReadXml(@"C:\GUI\buildermanageremail.xml");
DataView dy = ds3.Tables["buildstream4"].DefaultView;
BuildstreamComboBox.ItemsSource = dy; //Sets the collection of items from which to populate
BuildstreamComboBox.DisplayMemberPath = "value"; //Sets the path within an item to use for display
}
if (BuildmachineComboBox.SelectedIndex == 1)
{
ds3.Clear();
ds3.ReadXml(@"C:\GUI\buildermanageremail.xml");
DataView dz = ds3.Tables["buildstream5"].DefaultView;
BuildstreamComboBox.ItemsSource = dz; //Sets the collection of items from which to populate
BuildstreamComboBox.DisplayMemberPath = "value"; //Sets the path within an item to use for display
}
}
其中ds3
的肺癌:
DataSet ds3 = new DataSet();
有人有什麼想法嗎?
請問你BuildstreamComboBox看在XAML?它是否有子元素? – Heinzi 2011-04-19 05:50:54
哦,是的..它確實有以前的物品來源。忘記刪除他們感謝提醒! – jeremychan 2011-04-19 05:53:22