WIA304 - Building Line-of-Business Applications Fast With Microsoft Silverlight and Microsoft .NET RIS Services
Given a data model, RIA services quickly generates the domain service classes for your web layer. The generated classes include skeleton methods to get, insert, update and delete the entities. Business rules (such as required fields) are automatically passed through so that the UI can respond to them.
The uriMApper xaml element provides a way of routing URL patterns to xaml controls, making your Silverlight application more website-like, and preserving the functionality of the back button. It uses URLs in the pattern mysite.com#/Customers - the # ensures you're really staying on the same page, so the Silverlight control doesn't have to be reloaded.
A goal of RIA Services is to take away some of the pain of handling asynchronous events, giving you cleaner, more readable code.
RIA Services provides you with some additional Silverlight controls. One we looked at was the DataPagerControl, that attaches to a datagrid and returns pages of data, all with writing virtually no code.
The DataControlToolkit adds a few new Silverlight controls to get you going more quickly with editing data. For example, the DataForm control will provide appropriate input controls for each field on your object.
The ActivityControl can be wrapped round your input form. When its IsBusy property is set to true, it masks itself and shows a Please Wait animation. This property can be bound to your domain service class (that wraps the async calls), thus making it dead easy to give your users a synchronous experience.
To enforce security, the [RequiresAuthentication] and [RequireRole] can be added to methods, preventing them from running if the user doesn't have sufficient credentials.
WIA303 - Microsoft ASP.NET AJAX: Taking AJAX to the Next Level
I've never been a big user of Microsoft's AJAX offering - I felt their control toolkit wasn't particularly good-looking and wasn't flexible enough if you didn't want exactly what it did out of the box, and I found jQuery could do at least as much as I wanted - so I was interested to find out what improvements they've made to "take things to the next level".
In .NET 4.0 webforms, you can say <asp:ScriptManager EnableCdn="true" />, and it will automatically get all its script files from the CDN.
The MS Ajax Minifier is a new offering that's available as a command line tool or an MSBuild task that works in two modes: normal minification (that strips whitespace, etc.) or hypercrunching (that goes a lot further - shrinking variable names and removing unreachable code). I think hypercrunching is probably the coolest name Microsoft's come up with for any of its products for quite some time.
The minifier can also analyse your code and warn you of any problems it can recognise.
(As an aside, a nice way to edit your project file in Visual Studio is to right-click it and select Unload, then right-click and select Edit. I never knew that - I've always been opening it in a separate text editor.)
The new AJAX library isn't being shipped with VS2010 or .NET 4.0 - instead it's available as an open source project.
It's written as a pure js library, so it will work equally well in webforms, MVC, or plain html. It integrates seamlessly with jQuery, and all its controls are exposed as jQuery plugins.
start.js contains a script loader that will pull in any other scripts you need, and defined by the Sys.require() function. This makes it easy to ensure you get the all libraries you need, exactly once each. It also supports lazy loading, so you can load libraries at the point that you need them.
Items can be added to the page using Sys.create.dataView. This looks for elements with a class="sys-template", which are treated as templates. The contents of the template are repeated for each item in your data source, and data fields within the template are demarked using . An itemRendered event is fired for each item to allow you to perform your own custom tasks.
Sys.bind() gives a really easy way to bind an item list with a detail view. You specify an event that fires when an item in the list is clicked, which you then use to populate your detail view. Using templates for both means you have to write almost no code.
A major new feature is the client-side datacontext. This works much like the DataContext in LINQ2SQL in that it tracks changes to records in the browser,which can then be batched up into a single AJAX post when the save button is clicked. This also supports two-way binding, so you can have the text in html elements be automatically updated in response to the user changing the text in a textbox.
WIA401 - Enhancing the Design-Time Experience for Microsoft Silverlight 3
When developing controls to be used in Silverlight, bearing in mind how the designers will experience them in Blend can make a big difference to how ready they are to slap you.
A new feature in Blend is the ability to add sample data. This makes it much clearer what the control will look like at runtime, without having to access any live data.
Attributes can improve how the control appears both in Blend and at runtime. For example, giving a property Category and Description attributes puts the property into its own group in the designer, with tooltip text to indicate what its function is. Further attributes can change how the value is entered, how it is validated, where it appears in the list, etc.
All the design-time code is wasted once you come to deliver your final product, so it makes sense to separate your design-time code into a separate assembly, but putting it into separate projects in Visual Studio. To do this, you must follow a naming convention for the project (and thus dll) names, and put classes in each project with the same names. This will then be respected by the design environment. Your projects should be named *.Design, *.VisualStudio, *.Design.Editors, *.Expression.Design.
Behaviours are a powerful tool that allow you to specify a lot of functionality without any code. Some are available out of the box, such as making an item draggable, but you can also make your own, configurable by properties in the property box in Blend.
WIA307 - Cool Graphics, Hot Code: Visual Effects in Silverlight
(All samples from this session are available at http://www.wintellect.com/downloads/techedeurope2009.zip)
A class called PageTurn.cs is a class that encapsulates the Page-Turn framework. Given pairs of canvases (for the left- and right-hand pages), this provides a clean page-turning animation.
The WriteableBitmap, new in Silverlight 3, is the root of all sorts of visual goodness. This lets you generate images on the fly, as well as taking a snapshot of controls in the running application. This can be used for anything from drawing Mandelbrot Sets, to capturing frames from a video, producing a draggable magnifying glass or the much over-used Shiny Wet Black Floor effect.
[Aside: If your xaml contains a large picture, but you're scaling it down, then if you make a WriteableBitmap from this, telling it to scale up, Silverlight is clever enough to use the original large bitmap, rather than the smaller scaled one, thus avoiding pixelated blockiness.]
We saw a little more of HLSL for building custom pixel shaders too. It was developed by Microsoft and is used by DirectX, so is very high-performance. It's based on C and looks a little crazy, but it's maybe not as scary as I'd thought. We saw how this can also be used to generate the Wet Floor effect. This has the big advantage that it's real time, so if your original xaml changes, so does the reflection.
However, it's worth noting that (for now) Silverlight only uses the CPU to execute the pixel shaders; if it ever uses the GPU, we can expect much better performance.
DEV316 - Model-Based Testing Made Easy with Spec Explorer 2010 for Visual Studio
Spec Explorer explores your C# code and draws a state machine graph of the possible routes through it. This gives a different view of the model that can be (possibly) more easily compared with the original requirements. From this, it generates unit tests that will trace each route though the code.
It's a little bit crazy and I don't think I'll ever use it, and that's all I've got to say about that.