Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>pls, try putting the code below in your button's on click event handler:</p> <pre><code> DataGridCell cell = GetCell(1, 0); if (cell != null) { cell.Focus(); yourDataGrid.BeginEdit(); } </code></pre> <p>below is implementation for the GetCell method taken from here <a href="http://social.msdn.microsoft.com/forums/en-US/wpf/thread/63974f4f-d9ee-45af-8499-42f29cbc22ae" rel="noreferrer">Grabing controls from a DataGrid</a></p> <pre><code>public DataGridCell GetCell(int row, int column) { DataGridRow rowContainer = GetRow(row); if (rowContainer != null) { DataGridCellsPresenter presenter = GetVisualChild&lt;DataGridCellsPresenter&gt;(rowContainer); // try to get the cell but it may possibly be virtualized DataGridCell cell = (DataGridCell)presenter.ItemContainerGenerator.ContainerFromIndex(column); if (cell == null) { // now try to bring into view and retreive the cell gridPersons.ScrollIntoView(rowContainer, gridPersons.Columns[column]); cell = (DataGridCell)presenter.ItemContainerGenerator.ContainerFromIndex(column); } return cell; } return null; } public DataGridRow GetRow(int index) { DataGridRow row = (DataGridRow)gridPersons.ItemContainerGenerator.ContainerFromIndex(index); if (row == null) { // may be virtualized, bring into view and try again gridPersons.ScrollIntoView(gridPersons.Items[index]); row = (DataGridRow)gridPersons.ItemContainerGenerator.ContainerFromIndex(index); } return row; } static T GetVisualChild&lt;T&gt;(Visual parent) where T : Visual { T child = default(T); int numVisuals = VisualTreeHelper.GetChildrenCount(parent); for (int i = 0; i &lt; numVisuals; i++) { Visual v = (Visual)VisualTreeHelper.GetChild(parent, i); child = v as T; if (child == null) { child = GetVisualChild&lt;T&gt;(v); } if (child != null) { break; } } return child; } </code></pre> <p>hope this helps, regards</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload