public MainWindow() { InitializeComponent(); mediaPlayer = new MediaPlayer(); musicLib = new MusicLib(); musicLib.PrintAllTables(); // Console.WriteLine("Total songs = " + musicDataSet.Tables["song"].Rows.Count); // Get a list of all song IDs //DataTable songs = musicDataSet.Tables["song"]; //var ids = from row in songs.AsEnumerable() // orderby row["id"] // select row["id"].ToString(); // Put the ids in an ObservableCollection, which has Add & Remove methods for use later. // The UI will update itself automatically if any changes are made to this collection. songIds = new ObservableCollection <string>(musicLib.SongIds); // Bind the song IDs to the combo box songIdComboBox.ItemsSource = songIds; // Select the first item if (songIdComboBox.Items.Count > 0) { songIdComboBox.SelectedItem = songIdComboBox.Items[0]; } }
public MainWindow() { InitializeComponent(); mediaPlayer = new MediaPlayer(); musicLib = new MusicLib(); musicLib.PrintAllTables(); songIds = new ObservableCollection <string>(musicLib.SongIds); Console.WriteLine("Total songs = " + songIds.Count()); // Bind the song IDs to the combo box songIdComboBox.ItemsSource = songIds; // Select the first item if (songIdComboBox.Items.Count > 0) { songIdComboBox.SelectedItem = songIdComboBox.Items[0]; } }
public MainWindow() { InitializeComponent(); musicLib = new MusicLib(); mediaPlayer = new MediaPlayer(); try { musicDataSet = new DataSet(); musicDataSet.ReadXmlSchema("music.xsd"); musicDataSet.ReadXml("music.xml"); } catch (Exception e) { DisplayError("Error loading file: " + e.Message); } musicLib.PrintAllTables(); Console.WriteLine("Total songs = " + musicDataSet.Tables["song"].Rows.Count); // Get a list of all song IDs DataTable songs = musicDataSet.Tables["song"]; var ids = musicLib.SongIds; // Put the ids in an ObservableCollection, which has Add & Remove methods for use later. // The UI will update itself automatically if any changes are made to this collection. songIds = new ObservableCollection <string>(ids); // Bind the song IDs to the combo box songIdComboBox.ItemsSource = songIds; // Select the first item if (songIdComboBox.Items.Count > 0) { songIdComboBox.SelectedItem = songIdComboBox.Items[0]; } }
private void showDataButton_Click(object sender, RoutedEventArgs e) { musicLib.PrintAllTables(); }