Archive for the 'Silverlight' Category

Silverlight MathTutor Demo

Tuesday, July 10th, 2007

Messing around with SilverLight 1.1 last night I made a MathTutor demo. No big deal but it let me mess with the new builds, c# code-behind, events, animation, etc.

The scoreboard updates on a 1 second interval. All the updates happen from the c# code, but at the moment I’m using the Javascript setTimeout mechanism to trigger it since it wasn’t clear if the limited .NET supported by Silverlight had some good thread-safe timer mechanism.

Developing for Silverlight 1.1

Friday, July 6th, 2007

I’ve been messing around looking at what is involved with developing for Silverlight 1.1. My impression of the documentation available for the 1.1 version so far is that its pretty bad- but again, let me point out that I think its great that they shipped it even at this early stage. I’d much rather have the bits available with confusing docs than not at all.

One thing that took me a bit to figure out is that there are better docs on silverlight.net than there are in the Silverlight developer center on MSDN. The MSDN pages just have access to the downloads and some really high level overviews. The silverlight.net site at least has the quickstarts available in online form with easy reference to the source code. Playing with this a bit got me past the basics of getting one of the demos compiling myself and running.

The second issue is the version of Visual Studio needed. You need to run Orcas beta 1 to get the SDK templates to install and for debugging support. Visual Studio 2005 can work fine to build projects as long as you can do a few things yourself and don’t need the debugger. I think Orcas is supposed to be able to install side-by-side with Visual Studio 2005 but I don’t totally trust that. Luckly Microsoft is offering Orcas as a Virtual PC image which should be a great way to go.

If you want to build stuff yourself with Visual Studio 2005 just create a new DLL project. Delete the default control it makes for you and remove all the references. Select Add References and go to your \Program Files\Microsoft Silverlight and add all the managed DLLs you see there to your project. You probably don’t need them all but I didn’t want to mess around.

You can then create your project as a set of .CS, .XAML, .HTM and .JS files. Don’t forget to set the “Copy to output directory” property on your .XAML .HTM and .JS files so they appear in the target directory. In your XAML you can refer to your DLL like this-

    x:Class="Samples.Silverlight.CS.ScriptingCanvas;assembly=TestSilver1.dll"

Finally set the project to debug opening in the browser with the URL to your .HTM file. IE will give you a security warning everytime but once you bypass that you should be running.

Writing controls for WPF/E

Saturday, February 24th, 2007
One of my old buddies from the Avalon team Nick Kramer has a great post on building controls for WPF/E. This article has a ton of great tips for how to work with the current builds.
For controls he uses an interesting technique of putting the control in the WPF/E markup as a <Canvas> with an onLoaded event on each control that triggers the control creation-

<Canvas Loaded="javascript:MakeButton" Canvas.Top="100" Canvas.Left="20"/>

This brings up another thing that I was working on for the next build of LaunchE. I’m hoping to enable full markup of the controls more like this-
<TextBlock x:Name="ScrollText" Canvas.Top="50" Canvas.Left="20"
  FontFamily="Verdana" FontSize="12">Scroll value:</TextBlock>
<l:Button x:Name="Button1" Left="50" Top="100" Width="100" Height="20"
  Text="A Button" />
<TextBlock x:Name="ScrollText" Canvas.Top="150" Canvas.Left="20"
  FontFamily="Verdana" FontSize="12">More Text</TextBlock>
The idea is that a pre-processor scans through your XAML and interprets the tags in the LaunchE namespace (l: prefix). Those get reparsed an the XAML parser is fed the new tree.

Coming in the next build of LaunchE

Thursday, February 22nd, 2007

The first build of LaunchE that is online now is pretty basic. We considered waiting to make more progress but it made sense to try to get it out in the public sooner and get feedback as soon as possible. So please, let us know what you think either in the comments here or by email. We also welcome code submissions as long as you are willing to grant us the necessary copyright so that we can continue with our existing license.

Also I thought it would be useful to give everyone a heads up on the next things that are coming in the library. RadioButton and ScrollBar are both pretty much done and after that we will probably start working on some layout concepts like Grid.

One important decision that we are still wrestling with is control composition. Real WPF controls are all pretty much built out of other controls and can have any other controls embedded in them. In that model ScrollBar gets built out of 5+ other controls for the various regions.

So far we are not taking the same approach for LaunchE. My concern is that the quantity of controls was sometimes a perf issue even with compiled C# code, with the JavaScript platform we need to be careful to make sure it runs fast enough. So ScrollBar is itself one control that deals with its own sub-parts. This reduces some degree of flexibility, but I hope to still enable a Button control that has arbitrary other stuff embedded for its content.

Introducing LaunchE WPF/E Library

Tuesday, February 20th, 2007

Since Microsoft first introduced WPF/E in December we have been pretty excited to do some cool stuff with it. WPF/E itself is a very basic vector and media rendering tool, so building a framework for controls (and eventually layout) seemed like an obvious project to enable the use of this tool in real-world applications.

Today we are putting online the very first early-preview build of LaunchE, the WPF/E controls library. This version only supports Button and Checkbox, and only very basic support for those, but more controls and capabilities are coming soon.

LaunchE Basics Demo

Some key features-

Uses JavaScript inheritance to build sub-classed controls.

Ability to re-skin a control without inheritance (just replace the template XAML).

Support for adaptive layouts (for example, centering the text in the button control).

Events (just Click for right now).

Please check it out and send us feedback. Feel free to use it in your own projects, but at this point we are still likely to make breaking changes as we flush out its capabilites.

Check out a very simple demo of LaunchE

Download the JavaScript Source code (version 0.001)

WPF/E Photo Gallery Example

Saturday, February 17th, 2007

Mike Harsh shows Lester Lobo’s WPF/E photo viewer example that uses some nice reflections and some fake-3d. Unfortunately WPF/E only supports skews and rotations so you can’t do real perspective at all. Its possible to do some simple fake-3d that looks real, but the effects in this example just give me a “wrong” feeling. This is one of those cases where a visual designer can really earn their pay, since there are some careful things you can do to make the scene look more right by realizing that the vanishing point is in effect at infinity.

The history of this limitation is a bit interesting. WPF (Avalon) didn’t need the more complex transformations since it supports real 3D. WPF/E in theory is a strict subset of the WPF functionality so they didn’t add support for transformations that WPF itself can’t do. It would be great to see this improved over time so we can really emulate 3D.