开发者

How to call a c# method from javascript in window phone 7?

I wa开发者_运维知识库nt to detect swipe in web browser control in C# using JavaScript. I want to add some JavaScript to my web content and then if swipe occurs, call a method that loads another web content in the same web browser control.

I would like some sample code or any other suggestion to do this.

Thanks in advance


You'll need to use something to detect the swipe in javascript. I've been recommended to use touch.js but haven't had a chance to try this yet.

When you detect the swipe you can call out to native code using window.external.notify().

Be sure to set IsScriptEnabled="True" on the WebBrowser control and register an handler for the ScriptNotify event.
It's this event handler which would load the new content.


First of all, consider that gestures for a webbrowser control have it's own handlers. Now, if you don't need to pan/zoom or the like in the webbrowser control, it's not a problem.

Then you simply set the IsHitTestEnabled attribute to false, so that the web-browser no longer receives input. Then you can simply use the GestureService from the Silverlight Toolkit to handle the swipe/flick inputs.

I wrote some code on how to handle this, in another question: wp7 horizontal swipe selection

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜