0

I have a WPF application with a web browser control inside which is a silveriight application. Earlier, I have been able to call functions from WPF application to sliverlight application using HTML bridge.

Now, I have to do the opposite to this i.e. I have to call a function inside the WPF application from silverlight.
How can this be done?

1 Answer 1

2

You can do this by using the property as shown below:

C# part :

webBrowserControlName.ObjectForScripting = new ScriptInterface();

where ScriptInterface is as follows

[System.Runtime.InteropServices.ComVisibleAttribute(true)]
public class ScriptInterface
{

    public void CSharpMethod(string data)
    {
        MessageBox.Show(data);
    }
}

HTML part

in the page that you load in the web browser control do the following :

window.External.CSharpMethod('from html page to WPF');
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.