我可以为所有支持 Silverlight 2.0 的浏览器覆盖 Silverlight 中的上下文菜单吗?
这似乎是 Google 上的一个常见问题,但我找不到满意的答案(除非答案是“否”)。
我想在用户右键单击我的 Silverlight 应用程序时添加菜单项或显示自定义菜单。
我发现的最接近的东西捕获了 IE 中的上下文菜单,但不是 Firefox 中的上下文菜单,Chrome 显示了上下文菜单,然后显示了自定义事件。
It seems like a common question on Google, but I couldn't find a satisfactory answer (unless the answer is 'no')
I would like to add menu items or show a custom menu when a user right-clicks on my Silverlight app.
The closest thing that I found catches the context menu in IE, but not in Firefox, and Chrome shows the context menu and then shows the custom event.
(The tutorial I mentioned was here
http://silverlight.net/blogs/msnow/archive/2008/07/01/tip-of-the-day-14-how-to-right-click-on-a-silverlight-application.aspx)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这里你有一个实现,但它是 CTRL+左键单击,然后你会得到一个上下文菜单(关于文本,抱歉它是西班牙语):
http://www.albloguera.es/?p=29
另一种选择是通过 javascript 指出的,相当笨重的解决方案,不确定现在是否可以在当前 2.0 版本:-(。
祝你好运
布劳略
Here you have an implementation but it's CTRL+Left click, then you get a context menu (about the text, sorry it's in spanish):
http://www.albloguera.es/?p=29
Another option, is the one pointed out do it via javascript, quite chunky solution, and not sure if now it's working in the current 2.0 version :-(.
Good Luck
Braulio
Silverlight 中没有办法以本机方式执行此操作。
我相信其他地方提到的 Telerik 控件使用 HtmlBridge 来拦截上下文单击,然后绘制自己的菜单,但是它现在似乎无法与 Silverlight 2.0.40115 一起使用,所以也许 Microsoft 已经弥补了这一差距。
没有右键单击是基于安全考虑的设计决策,而不是技术决策。 不过我相信微软团队正在考虑在未来版本(甚至可能是 v3)中允许上下文菜单
There is no way to do this natively in Silverlight.
I believe that the Telerik control noted elsewhere uses the HtmlBridge to intercept the context click, then draw their own menu, however it does not appear to be working with Silverlight 2.0.40115 now, so maybe Microsoft have closed that gap.
Having no right click is a design decision based on security concerns, rather than a technical one. However I believe that the Microsoft team are considering allowing context menu's in future versions (perhaps even v3)
根据我对 Telerik 上下文菜单的使用,我得出的结论是,它似乎可以在 IE、Chrome 和 Firefox 上正常工作。
看看,http://demos.telerik.com/silverlight/#ContextMenu/FirstLook< /a>
I've come to the conclusion that it seems it is possible based on my use of Telerik's context menu which works fine on IE, Chrome and Firefox.
Check it out, http://demos.telerik.com/silverlight/#ContextMenu/FirstLook