window.external.notify 传递字符串以外的数据

发布于 2024-12-20 00:28:30 字数 1339 浏览 5 评论 0原文

我正在尝试编写一个 Windows Phone 应用程序,并且想在用户想要执行操作时调用委托。但问题是该操作必须在网页中执行,并且该事件必须在应用程序内部处理。我知道这不是一个完美的设计,但我所做的只是尝试探索修改从网络浏览器控件传递回应用程序的数据的方法。

这是我的问题,

        +---------------------------------------------+
        | Inside App (C# Code Behind)                 |
        |         App Data.                           |
        |                                             |
        |   Delegate that handles the event.          |
        |      ^       +----------------------+       |
        |      |       |Webbrowser Control    |       |
        |      +       |                      |       |
        |      |       |                      |       |
        |      +------------+Action Performed |       |
        |              |   (HTML Control)             |
        |              |                      |       |
        |              |                      |       |
        |              +----------------------+       |
        |                                             |
        |                                             |
        +---------------------------------------------+

我目前正在使用 window.external.notify(somestrings) 并使用反射来调用后面代码中的方法。除了传递字符串之外,我还可以传递一个通用 Object 吗?当传递给 C# 代码时,该对象稍后可以类型转换为委托对象,然后可以调用该委托对象?

如果不是委托,我可以通过传递函数名称来调用后台代码 (C#) 中属于应用程序一部分的方法吗?

I am trying to write a windows phone app and I want to invoke a delegate when a user wants performs an action. But the problem is the action has to be performed in the webpage and the event has to be handled inside the app. I know this is not a perfect design, but all I am doing is trying to explore ways to modify the data that is being passed from a webbrowser control back to the application.

This is my Question,

        +---------------------------------------------+
        | Inside App (C# Code Behind)                 |
        |         App Data.                           |
        |                                             |
        |   Delegate that handles the event.          |
        |      ^       +----------------------+       |
        |      |       |Webbrowser Control    |       |
        |      +       |                      |       |
        |      |       |                      |       |
        |      +------------+Action Performed |       |
        |              |   (HTML Control)             |
        |              |                      |       |
        |              |                      |       |
        |              +----------------------+       |
        |                                             |
        |                                             |
        +---------------------------------------------+

I am currently using window.external.notify(somestrings) and using reflection to invoke the method in the code behind. Other than passing around a string can I pass a generic Object which when passed to C# code which can later be type cast to a delegate object which can then be invoked?

If not for delegates can I invoke the method that is part of the app in the code behind (C#) by just passing the function's name?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我是有多爱你 2024-12-27 00:28:30

只能通过 Notify() 方法传递字符串。

您可以尝试调用通过反射传递的方法名称。或者,如果您知道在设计时可能调用的方法,则可以传递一个值,然后将其在代码中转换为您要调用的方法。

It's only possible to pass a string via the Notify() method.

You could try invoking the method name you are passing via reflection. Alternatively, if you know the methods you may invoke at designtime you could pass a value which you translate in code to the method you're after.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文