Today I’m making a demo application. It’s a simple PDF reader in Silverlight and it uses two new features. The Silverlight Out Of Browser (SLOOB) with elevated permissions, and the WebBrowser Control. Those of you who’ve written some WPF might already be familiar with the WebBrowser control and what it can do. In Silverlight, it’s basically an html-renderer for when you’re out of browser.
Let’s start by making a new Silverlight application. Create it with a website attached to it. First some basic XAML code to create the WebBrowser control:
<Grid x:Name="LayoutRoot" Background="White" Margin="50">
<Border BorderBrush="Black" BorderThickness="10" >
I’ve chosen to add a margin and a border for increased visibility and separation.
Try and run this application. You’ll see how the WebBrowser control does nothing while in browser.
Now go to your Silverlight project file and select Properties. You’re going to allow OOB deployment.
Next, restart your application and install it to your desktop.
This next part is important, set your Silverlight project file as your startup and go back into Properties. This time go to the Debug menu and select your OOB program as the default debug target. This way you won’t have to reinstall it every time you’ve made a change.
Lastly, simply set myWebbrowser’s source to a pdf file located in your Client Bin.
<WebBrowser Name="myBrowser" Source="example.pdf"/>
Now relaunch your application and you’ll find you have a fully functional PDF viewer with separate interaction areas. This means that the context menu for the PDF viewer is separate from the one in Silverlight.
Where you go from here is up to you. Good luck!