Silverlight Datagrid select on right click

后端 未结 5 1832
半阙折子戏
半阙折子戏 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:11

    I tried a slightly different approach using the LoadingRow event in the DataGrid. I don't like using that particular event if I don't have to, but since I wasn't working with large amounts of data, it works out pretty well. The only thing I don't have in this sample is the command to use to perform the action. You could use a command on the DataContext object or some other mechanism.

        private void DataGrid_LoadingRow(object sender, DataGridRowEventArgs e)
        {
            var contextMenu = new ContextMenu();
    
            var deleteMenuItem = new MenuItem {Header = "Delete User"};
    
            contextMenu.Items.Add(deleteMenuItem);
    
            ContextMenuService.SetContextMenu(e.Row, contextMenu);
    
        }
    

提交回复
热议问题