I want to be able to select a specific cell in Silverlight 3.0 DataGrid and put it in edit mode. I can use VisualTreeManager to search for a cell. How to switch to edit mode?
Each DataGridCell looks like this in VisualTreeManager:
System.Windows.Controls.DataGridCell System.Windows.Controls.Grid System.Windows.Shapes.Rectangle System.Windows.Controls.ContentPresenter System.Windows.Controls.TextBlock System.Windows.Shapes.Rectangle System.Windows.Shapes.Rectangle
with a TextBlock containing the text I want to change.
Update
Following @AnthonyWJones suggestion, here is how I tried to do this using BeginEdit ().
I wanted it to be simple, so I decided to select the column in the first row. Even this turned out to be above my knowledge of SL! In the end, I get the first line by creating a firstRow field to store it:
private DataGridRow firstRow;
Added LoadRow handler in DataGrid:
LoadingRow="computersDataGrid_LoadingRow"
and
private void computersDataGrid_LoadingRow(object sender, DataGridRowEventArgs e) { if (this.firstRow == null) this.firstRow = e.Row; }
and then adding a button to the panel to start editing:
private void Button_Click(object sender, RoutedEventArgs e) { this.dataGrid.SelectedItem = this.firstRow; this.dataGrid.CurrentColumn = this.dataGrid.Columns[4]; this.dataGrid.BeginEdit(); }
I press the button and the correct cell is selected, but it does not go into editing on the cell. This requires a manual click.
ssg31415926
source share