private void addNewTest() { if (String.IsNullOrWhiteSpace(TestName.Text)) { //TODO add warning msg return; } string newFileName = Path.Combine("CPUS\\cpu\\tests", TestName.Text + ".asm"); if (File.Exists(newFileName)) { //TODO add msg return; } File.Create(newFileName); var newTest = new Test(TestName.Text, string.Empty, newFileName, this); Tests.Add(newTest); Tests = Tests.OrderBy(t => t.Name).ToList(); TestDataGrid.ItemsSource = null; TestDataGrid.ItemsSource = Tests; TestDataGrid.SelectedItem = TestDataGrid.Items[Tests.IndexOf(newTest)]; TestDataGrid.Focus(); //TestDataGrid.GetBindingExpression(ItemsControl.ItemsSourceProperty).UpdateTarget(); }