Silverlight Datagrid select on right click

后端 未结 5 1862
半阙折子戏
半阙折子戏 2021-01-05 16:34

Is there a way for a right click event to select a row in toolkit datagrid?

I\'m using toolkit context menu which works nicely, but the problem is, only left click i

5条回答
  •  温柔的废话
    2021-01-05 17:02

    You can find a solution here.

    Basically it goes like this:

    private void dg_LoadingRow(object sender, DataGridRowEventArgs e)
    {
        e.Row.MouseRightButtonDown += new MouseButtonEventHandler(Row_MouseRightButtonDown);
    }
    void Row_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
    {
        dg.SelectedItem = ((sender) as DataGridRow).DataContext;
    }
    

提交回复
热议问题