Silverlight Datagrid 右键单击选择
有没有办法让右键单击事件在工具包数据网格中选择一行?
我正在使用工具包上下文菜单,它工作得很好,但问题是,只有左键单击才能选择行,如果我希望上下文菜单正常工作,我需要右键单击才能执行此操作。
任何帮助表示赞赏
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
您可以在此处找到解决方案。
基本上是这样的:
You can find a solution here.
Basically it goes like this:
他的行为可以为你带来帮助(受到这个 博客文章):
像这样使用它:
He's a Behavior which will do the trick for you (inspired by this blog post):
Use it like this:
谢谢好主意。但如果指定了 UnloadingRow 事件可能会更有效。
Thanks good idea. But the with UnloadingRow event could have been more effective had been specified.
Codeplex 上的这个开源项目开箱即用地支持这种行为,并且做的远不止于此:
http://sl4popupmenu.codeplex .com/
This open source project on Codeplex supports this behavior out of the box and does much more than this:
http://sl4popupmenu.codeplex.com/
我尝试了一种稍微不同的方法,使用 DataGrid 中的 LoadingRow 事件。如果没有必要,我不喜欢使用该特定事件,但由于我没有处理大量数据,因此效果很好。此示例中唯一没有的是用于执行操作的命令。您可以在 DataContext 对象上使用命令或某种其他机制。
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.