How can I put a Silverlight 3 DataGridCell into edit mode in code?

前端 未结 2 1833
旧巷少年郎
旧巷少年郎 2021-01-18 14:26

I want to be able to pick a specific cell in a Silverlight 3.0 DataGrid and put it into edit mode. I can use the VisualTreeManager to locate the cell. How do I switch to e

2条回答
  •  走了就别回头了
    2021-01-18 14:54

    I'm not sure why you need to find the DataGridCell using VisualTreeManager nor do I know currently how you would properly start editing . You may get away with simply setting the cell's visual state to editing.

     VisualStateManager.GoToState(myDataGridCell, "Editing", true);
    

    I'm not sure how the grid behaves when you do something like the above. You may find things goe a bit pearshaped if you need DataGrid to help you revert changes to a row.

    The "standard" approach would be to set the DataGrid SelectedItem property to the item represented by the row, set the CurrrentColum property to the DataGridColumn object that represents to the column in which the cell is found. Then call the BeginEdit method.

提交回复
热议问题