3

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?

Ajai
  • 3,440
  • 5
  • 28
  • 41

1 Answers1

1

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.

Matt Lacey
  • 65,560
  • 11
  • 91
  • 143
  • 2
    yeah, you could pass a JSON or XML value to notify() and deserialize it in the code behind. – wmute Aug 01 '12 at 18:42