public DiscSelection() { this.InitializeComponent(); this.ShowCloseButton = false; btnSelect.IsEnabled = false; // get the mainwindow MainWindow mw = Application.Current.Windows.OfType <MainWindow>().FirstOrDefault(); int numRowsCount = mw.dgGameList.SelectedItems.Count; if (numRowsCount != 1) { return; } GamesLibraryModel drv = (GamesLibraryModel)mw.dgGameList.SelectedItem; if (drv == null) { return; } int romId = drv.ID; // create new GameLauncher instance GameLauncher gl = new GameLauncher(romId); LaunchString = gl.GetCommandLineArguments(); // choose disc string path = Game.GetGame(romId).gamePath; string[] sheets = DiscScan.ParseM3UFile(path); if (sheets == null || sheets.Length == 0) { MessageBox.Show("ERROR: Track Sheets Could Not be Parsed."); this.Close(); } DiscArray = sheets; this.Title = "Choose Disc to Launch"; this.Refresh(); List <DSel> g = new List <DSel>(); for (int i = 0; i < DiscArray.Length; i++) { DSel ds = new DSel(); ds.DiscNumber = i; ds.DiscName = DiscArray[i]; g.Add(ds); } // make sure list is ordered g.OrderBy(a => a.DiscNumber); dgReturnedGames.ItemsSource = g; }