web 2.0

News: Windows Phone 7 Phones Running Silverlight


Silverlight Libraries Source Code Will Be Available

On January 17 2008, Scott Guthrie announced the availability of .NET Framework Source Code under read-only reference for debugging purposes. That was great news indeed for .NET developers especially for those who had used .NET Reflector. This will solve a lot of debugging mysteries behind the "[External Code]" in the call stack. But hold on a sec, there is greater news for Silverlight developers, the source code of Silverlight libraries will be available as well according to his reply to our comment. I asked him if Silverlight source code could be opened. "Yes - we'll be releasing the source and enabling debugging for the Silverlight libraries as well once they ship." he replied. Although his reply is not an official announcement, it significantly leverages the possibility of having Silverlight source released.More...

Tags:

News | Silverlight 2.0

Open File Dialog in Silverlight

Silverlight 2.0 Alpha introduced OpenFileDialog control which allows Silverlight applications to open and read *local* files outside Isolated Storage. It's better than the HTML <input> tag which is widely used for uploading files in web page. Well, like HTML <input>, OpenFileDialog could be used to build a file uploader quickly. Both must prompt user to select files. But unlike HTML <input>, OpenFileDialog control could be used to read and process the file data locally in Silverlight application. This is pretty powerful since Silverlight application will not need to upload the files to server for processing. What's more is that OpenFileDialog allows user to select multiple files at once. No need to create multiple instances of OpenFileDialog for that. Let's see some examples:More...

Tags:

Silverlight 1.1 | Silverlight 2.0 | Tutorial

Fluid Canvas in Silverlight

So you wanted the root canvas to scale proportionately to the host element to achieve fluid layout, and you tried setting Width=”100%” or Height=”50%”, but then horror struck because of this parser error: “Invalid attribute value 100% for property Width/Height”.  Ok, to tell you the truth you cannot set “%” to the Width and Height properties because the % is not accepted. Read on for the solution.

The BrowserHost instance has the Resize() event which fires every time the host element is resized and the ActualWidth/ActualHeight properties which tells the dimension of the host element. So, to automatically resize the root canvas, handles the BrowserHost.Resize() event, and from there you can resize the canvas. Let’s sum it up with VB.NET and C# code:More...

Tags:

Silverlight 1.1 | Tutorial

Creating Cool Draggable Window in Silverlight

 
 

Silverlight is often dubbed as the would-be better platform for creating Rich Internet Applications. But to date, I’ve seen only applications sitting duck in the browser. Well, I’m not saying that those are not great RIA, but for goodness sake, I want to see something different like a Silverlight application flying around in the browser among HTML elements, or at least a window in Silverlight that could be dragged around. This motivates me to create a proof of concept.

This tutorial basically demonstrates how to create and overlay a draggable window on HTML body in Silverlight, using managed code and DOM. For simplicity, this sample uses an alpha-blended background PNG image to cast the shadows and make the ‘see-through glass’ effect on the LCD screen.More...

Tags: ,

Silverlight 1.1 | Tutorial

Silverlight Can Go Full Screen and Back

So you want your Silverlight video player to play in full screen? No problem! It's pretty easy to go into full screen mode, hiding everything including browser frame, in Silverlight. It's just a line of code:

Application.Host.Content.IsFullScreen = True 

While in full screen mode, user can press ESC key to exit full-screen mode, or your Silverlight application can exit programatically by:

Application.Host.Content.IsFullScreen = False

You can easily toggle between full screen modes by:

VB.NET
Application.Host.Content.IsFullScreen = Not Application.Host.Content.IsFullScreen

C#
Application.Host.Content.IsFullScreen = !Application.Host.Content.IsFullScreen;

The Content class exposes two events FullScreenChanged() which fires when the full screen mode is changed, and Resized() event which fires when the host element is resized (not when browser is resized). You can use these events to detect when user gets into and out of full screen mode. It's also worth mentioning that all keyboard events will not fire in full screen mode, only mouse events will. This feature is to protect user from password spoofing and other impersonation attacks.

View Online Demo - Download Source Code (14.34 kb)

Tags:

Silverlight 1.1 | Silverlight 2.0 | Tutorial

Silverlight To Light Up Olympics 2008

Folks, the Olympics 2008 Games in Beijing, China is coming soon on 08/08/08. Sports aside, the most exciting news to me is in fact the deal between Microsoft and NBC to broadcast the Olympics games over the web via Silverlight 2.0. Over 3000 hours of live and on-demand videos will be available exclusively to anyone with Silverlight 2.0 plug-in installed. In layman's terms, you can watch every second of all the games if you have Silverlight 2.0. For more details, read the blog post by Soma Segar, corporate vice president of the Microsoft Developer Division.

Now let's talk business. Thousands if not millions of people will download and install Silverlight 2.0 plugin. This will definitely bring the "98% of web users can run Flash Silverlight applications" closer to reality. We Silverlight developers would be able to deploy our Java Silverlight applications worry-free over the web, because 98% of all web users could use them right away. And Microsoft might not have to deal with antitrust lawsuits, because they wouldn't need to distribute Silverlight in the automatic Windows Update.

I'll definitely keep an eye on NBCOlympics.com for videos of the Olympics.

Tags:

Silverlight 2.0 | News

Store and Read Files in Client's Computer Using Isolated Storage

Says your application downloads some data files and need to save them locally in the client's computer for subsequent uses. Well, Silverlight in partial-trust mode cannot access client's file system directly, because that would seriously compromise the client's computer. So, Silverlight team devised an ingenious solution by creating a sandboxed virtual file system as known as Isolated Storage. As the name implies, each Silverlight application is given an isolated storage for its own use, up to about 1MB in Silverlight 1.1 Alpha. This opens up a lot of good possibilities like saving user settings, temporary files, form inputs, etc. Without further ado, let's see how to save a text file:More...

Tags:

Silverlight 1.1 | Tutorial

How to Get Information About Browser, Web Page and Cookies

 

As Silverlight application is hosted in web browser, you might somehow want to get some information about it like browser name, version, platform or user agent. Or you might want to check whether cookies are enabled before reading/writing them. It's pretty easy indeed, because Silverlight exposes the references to the browser and page instances in System.Windows.Browser namespace. They're all there. HtmlPage holds the information of the current web page, and BrowserInformation holds that of the browser. Here's a quick example of how to get the name of the browser:More...

Tags:

Silverlight 1.1 | Tutorial

Execute Code String at Runtime with Silverlight 2.0 DLR

Requisites

  • Microsoft Visual Studio 2008
  • Silverlight 1.1 Alpha November Refresh or Newer

Introduction

One of the best additions in Silverlight 2.0 is the implementation of the Common Language Runtime and then the Dynamic Language Runtime, both of which were missing in Silverlight 1.0. Let’s dig a bit deeper in this CLR and DLR thing.

Silverlight 2.0 CLR is a stripped down version of .NET Framework 3.5 featuring the same type system, JIT compiler, garbage collector and a shipload of the same .NET 3.5 namespaces. Silverlight CLR allows .NET code to execute in a sandboxed environment on the client-side. But here’s the problem: Full .NET Framework has the full implementation of System.CodeDom framework which allows .NET code compilation at runtime, but Silverlight CLR strips out 99% of System.CodeDom namespace for security and space concerns. Therefore, you can no longer compile .NET code through the CodeDom in Silverlight. This is when DLR comes to rescue!More...