private static object ResetNewItemTemplate(object obj) { DataGridControl datagrid = obj as DataGridControl; if (null == datagrid) { return(null); } // Get the row for CollectionView.NewItemPlaceholder DataGridRow row = datagrid.GetRow(CollectionView.NewItemPlaceholder); if (null == row) { return(null); } // Ensure it's template is correct ControlTemplate template = GetTemplate(datagrid); if (null == template) { template = GetDefaultTemplate(datagrid); } if (row.Template != template) { row.Template = template; row.UpdateLayout(); } return(null); }
private object ResetNewItemTemplate(object arg) { DataGridRow row = DataGridHelper.GetRow(MainGrid, MainGrid.Items.Count - 1); if (row.Template != loadRowsControlTemplate) { row.Template = loadRowsControlTemplate; row.UpdateLayout(); } return(null); }
private static void OnDataGridRowMouseLeftButtonDown(object sender, MouseButtonEventArgs e) { DataGridRow row = sender as DataGridRow; if (null == row) { return; } DataGridControl datagrid = VisualTreeHelperExtended.GetAncestor(row, typeof(DataGridControl)) as DataGridControl; if (null == datagrid) { return; } if (CollectionView.NewItemPlaceholder == row.Item) { ControlTemplate template = GetTemplate(datagrid); if (row.Template == template) { row.Template = GetDefaultTemplate(datagrid); row.UpdateLayout(); datagrid.CurrentItem = row.Item; // 3/23/2010 - Get the first non-read only column (http://www.actiprosoftware.com/Support/Forums/ViewForumTopic.aspx?ForumTopicID=4710) DataGridColumn column = datagrid.Columns.FirstOrDefault(col => !col.IsReadOnly); if (column != null) { DataGridCell cell = VisualTreeHelperExtended.GetAncestor(column.GetCellContent(row), typeof(DataGridCell)) as DataGridCell; if (cell != null) { cell.Focus(); } } datagrid.BeginEdit(); } } }