Silverlight Datagrid右键单击选择 [英] Silverlight Datagrid select on right click

查看:131
本文介绍了Silverlight Datagrid右键单击选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在使用工具箱上下文菜单,它的工作原理很好,但问题是,只有左键单击才能选择行,如果我想让我的上下文菜单正常工作,我需要右键单击才能使用。



解决方案

您可以找到解决方案这里



基本上就是这样:

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


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 is able to select rows, and I need right click to be able to do that if I want my context menu to work properly.

Any help is appreciated

解决方案

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;
}

这篇关于Silverlight Datagrid右键单击选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆