As I mentioned yesterday I think the major announcement around Silverlight is the integration with the "CoreCLR". Scott thinks so also (see 2a and 4).. btw thats a post worth reading..
So ignoring all the UI goodness for a few moments, lets imagine I just want to avoid using all that nasty JavaScript and would rather use C# in the browser. Well why not just create an empty transparent canvas and use Silverlight as a .NET hosting container?
A contrived example of how this works in practice is:
Create a simple HTML page:
<div id="fooBlock">Hello World</div>
Add in a Silverlight code container block, and our associated XAML with a Canvas on it, in my case I decided to host an Image inside the Canvas for good looks..
<div id="SilverlightControlHost" > <script type="text/javascript"> createSilverlight(); </script> </div>
the CreateSilverlight call just instantiates a new XAML object which is hosting Page.xaml. Note the property set of enableHtmlAccess to true which allows the managed instance to get access back to the client side DOM.
Sys.Silverlight.createObjectEx({ source: "Page.xaml", parentElement: document.getElementById("SilverlightControlHost"), id: "SilverlightControl", properties: { width: "0px", height: "0px", version: "0.95", enableHtmlAccess: true }, events: {} });
Now the default view of this would look like:
But lets say we added the following lines of code in our managed load event:
HtmlElement el = HtmlPage.Document.GetElementByID("fooBlock");el.SetStyleAttribute("color", "Red");el.SetProperty("innerText", "foo");
Now we get:
HtmlPage returns us the current page instance, if we are allowed to see it. And from there we can walk the DOM using a new set of classes under the System.Windows.Browser namespace.
Not only can you manipulate the DOM from managed, but you can call into managed from JavaScript, or fire events in both directions. This gives you a fairly tight glue to get even your standard web apps humming with managed goodness.
I dont think the potential impact of this can be understated, while I fully expect the power of .NET to be used in anger in combination with the richer user experience that you get with Silverlight, there is equal opportunity to make sure your AJAX hums even better by doing more sophisticated work client side using .NET.
If you have Beta 1 of Orcas, get started by just creating a new Silverlight project! - you can go download the extensions for Silverlight as well as the 1.1 SDK (remember to install the 1.1 Alpha of Silverlight to make sure you get the new assemblies like System.Silverlight) and check out the QuickStarts at silverlight.net
Of course, you dont want to end up just writing a desktop app inside a browser window, or do you?