开发者

Auto-edit row in a Silverlight DataGrid

开发者 https://www.devze.com 2023-02-03 22:26 出处:网络
Is it possible for the DataGrid to automatically enter edit mode when the us开发者_JAVA百科er starts typing on the keyboard, without having to hit F2 or double-click with the mouse first?

Is it possible for the DataGrid to automatically enter edit mode when the us开发者_JAVA百科er starts typing on the keyboard, without having to hit F2 or double-click with the mouse first?

I've tried those 2 solutions:

Define only a CellEditingTemplate (no CellTemplate) : doesn't work. the datagrid always displays a textbox but the user still has to double-click or press F2 to enter edit mode

Handle KeyDown event and call BeginEdit:

private void DataGrid_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
{
    (sender as DataGrid).BeginEdit();
}

This works, but I lose the first key the user has pressed. I could work around this problem but I'm looking/hoping for a better solution.

Thank you!

0

精彩评论

暂无评论...
验证码 换一张
取 消