using System.Windows.Browser;
Use above mentioned namespace for communication. We will use Html communication bridge to communicate with the C++ host.
Use following statement to register the Communicator object. We will get this communicator object in C++ silverlight host using IDispath
HtmlPage.RegisterScriptableObject("Communicator", this);
Write another function in Silverlight application which we will call from C++ Silverlight host.
[ScriptableMember]
public void SetDataInTextBox(string strData)
{
txtData.Text = strData;}
using System.Windows.Browser;
namespace SilverlightTestApp
{
public partial class MainPage : UserControl{
public MainPage(){
HtmlPage.RegisterScriptableObject("Communicator", this);InitializeComponent();
}private void ClickMe_Click(object sender, RoutedEventArgs e){
MessageBox.Show("Button click handler is in Silverlight :)", "SilverlightTestApp", MessageBoxButton.OK);
}[ScriptableMember]public void SetDataInTextBox(string strData){
txtData.Text = strData;
}
}
I am not trying to explain Silverlight developmentment issues here but I would like to say that same things we do for Silverlight and Java Script interaction. If someone is not familiar with above code, google Silverlight and JavaScript interaction. Almost every Silverlight book covers this topic.
Read more: Codeproject