private void Window_Loaded(object sender, RoutedEventArgs e) { if (isEdit) { tbTitle.Text = "编辑" + testItem.TestName; } else { testItem.TestStartDate = testItem.TestEndDate = DateTime.Now.ToString("yyyy/MM/dd"); } Binding b = new Binding() { Source = testItem }; grid.SetBinding(Grid.DataContextProperty, b); testManagerBLL = new BLL.TB_TestManager(); }