Web Browser Control in Silverlight 4


I have been playing with Silverlight 4 for a while now. I know it’s too late probably to talk about some of the new features of Silverlight 4 since Scott Gu already have announced Silverlight 5 to be made available in early 2011, but I have been rather quite busy with my day job Smile. Also I left Target India and joined Misys Software as Senior Architect – so as a whole on the professional front I have been little busy lately. Anyway, it never too late.

Among the many features included newly in Silverlight 4, max importance have been on enabling and adding features that would help use Silverlight for Business Application Development specially of Enterprise scale similar to other UI technologies like WPF, Win Forms (I know people are still using it for new enterprise business apps), ASP.NET Web Forms and ASP.NET MVC (both with and without Ajax).

Silverlight 4 now supports Web Browser control that was long present in Win Forms. The Web Browser control can load a HTML page – it’s truly a mini IE. Note that Web Browser control can show content only in Full Screen mode. When it’s running within a browser embedded it does not display any content –

image

Since Sliverlight 4 has started officially supporting Google Chrome (though earlier also it used to work) I thought of using Chrome for this post.

So to use Web Browser control, Silverlight 4 must have to run out of browser. To load a page/HTML content or any browsable content (that browser can interpret like ASP.NET web page), use the Source property of the Web Browser control –

<WebBrowser x:Name=”webBrowser” Source=”https://caniruddha.wordpress.com/” /> – XAML
webBrowser.Source = https://caniruddha.wordpress.com/; – code

You can also use the Navigate and NavigateToString methods. While Navigate accepts a sting for URL, NavigateToString accepts a Uri object –

webBrowser.Navigate(new Uri(“https://caniruddha.wordpress.com/”));
webBrowser.NavigateToString(https://caniruddha.wordpress.com/);

image

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s