Without the slightest of doubts it has been concluded in the .NET developers community that, Silverlight is great platform to build LOB applications. It has taken all the developers by storm since its inception just three years ago. Web, Desktop and now mobile a Silverlight app thrives in every space. In this post I will talk about one of my favourite feature in this great technology. It is about the browser integration and how can you play with DOM. I also showcase a very cool example to demonstrate this feature. The complete solution is available for download at the end of this post. So let me first talk about the sample app that we are going to build. We shall be using Bing Web Api. I won’t getting into much details of this api but will redirect you to the right place if you want to learn more about this.
So we will develop a Silverlight app that will allow the user to enter their search query in the TextBox and clicking on the Search button , the Bing Api using JSON protocol will fetch us the results. These results will be then displayed in the ListBox of the application. Refer to the screen shot of the application below
So let us get started with it.
SILVERLIGHT AND BROWSER INTEGRATION
First thing first, to enable this integration you must ensure that ‘enableHtmlAccess’ attribute is set to true in your Silverlight plugin code.
I have the Search function which has one parameter , searchText. This function will be called from the Silverlight code. This function triggers a callback function called SearchCompleted, let us have look into this function now.
Notice this class is decorated with ScriptableType attribute which makes all this possible. If you miss these attributes you would get error. Let us now jump to now our other class which binds the ListBox in Silverlight app.
Have a great day. Cheers !