I would like you to look take at my previous article Host_Silverlight_In_ATL.aspx before continue with this one. In this article we will talk about communication b/w C++ Silverlight host and Silverlight application which means we can call a method of Silverlight app from C++ Silverlight host. 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)
{
Write another function in Silverlight application which we will call from C++ Silverlight host.[ScriptableMember]
public void SetDataInTextBox(string strData)
{
txtData.Text = strData;}
Complete code for the Silverlight page.using System.Windows.Browser;
namespace SilverlightTestApp
{
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