Archive for January, 2010
WPF Elements 2.0 is here!
We’re proud to announce the release of WPF Elements 2.0, the latest version of our package of controls for Windows Presentation Foundation. WPF Elements 2.0 includes four great new controls to quickly provide an even richer user experience to your applications, five good looking themes based on Microsoft Office and Expression Blend and many enhancements to the Elements 1.0 controls.
CoverFlow
CoverFlow is a list control that presents the selected item front and centre, with the unselected items arranged in a pseudo-perspective view around it. It provides a visually attractive and nicely animated way to present visual collections such as collections of photos, pictures or charts.
You can read more about CoverFlow, with link to a live demo, here.
ColorPicker
The ColorPicker control allows users to select colors in three different ways:
- Standard colors: a list of the built-in WPF colors displayed as a list of swatches along with their common names.
- Custom colors: allows users to mix their own colors using sliders or text boxes to specify the red, green, blue and alpha channels.
- Palette mode: similar to the color picker seen in Microsoft Office. This allows you to define the palette for your application so as to encourage users towards choices that work well together. You can customise the palette contents, arrangement and tooltips.
Here’s the palette view, showing a colour palette appropriate for modern graphic designs:
Here’s the custom color mode that gives the user full control to mix their own color. The colors on each of the sliders change dynamically making it very easy to see how changing each color channel will affect the result.
By providing your own style for the ColorPicker control, you can define which modes are available, style each mode however you like, or even have the ColorPicker displayed inside a window instead of a drop down.
AutoCompleteBox
The AutoCompleteBox helps to save typing and reduce errors by providing users with suggestions as they type. The user can quickly choose a suggestion with the arrow keys and thus “auto-complete” their entry.
To avoid confusing the user with too many suggestions, you can configure the AutoCompleteBox to limit the maximum number of suggestions to display at a time, and also not to display any suggestions until the user has typed a reasonable number of characters. You can also implement your own suggestion provider to perform custom matches, for example against custom sources such as the file system or using custom strategies such as matching initials (e.g. for WL suggest WriteLine).
PromptDecorator
This control can be attached to other controls to display a prompt telling the user what the control is for. The prompt is overlaid on the other control, conserving screen space and giving a smooth modern appearance, but disappears when the user clicks on the control so as to keep the control free of clutter when the user wants to type into it. The PromptDecorator can easily be styled to customize the look of the prompt allowing it to display images as well as text.
Here is the PromptDecorator being used in 4 different ways. The first one is simply being applied to a TextBox. The second one is also applied to a TextBox, but has been given a custom prompt template to include the magnifying glass. The next one shows the PromptDecorator being applied to an editable ComboBox. And the last one is being applied to the AutoCompleteBox.
Take it for a spin
If you have .NET 3.5 installed and want to have a play around with all of the controls included in WPF Elements, then you can see it live here. This also shows the cool new themes. You can also download a trial copy to try it out in your own applications.
We are always open for suggestions for improving these controls or ideas of more controls that you want to see. Put up a post on our forum and let us know!
Moving from LINQ to SQL to LightSpeed
Tagged as LightSpeedLINQ to SQL has been a very popular technology with SQL Server users, providing far greater ease of use than previous Microsoft data access technologies and introducing many .NET developers to the concept of object-relational mapping. However, LINQ to SQL delivers only very basic domain modelling capabilities — no aggregates, no value objects, etc. Not to mention that it’s tightly coupled to SQL Server and that Microsoft, who are trying to encourage adoption of the Entity Framework instead, are no longer enhancing LINQ to SQL.

Figure 1. Microsoft’s roadmap for the popular LINQ to SQL framework. (Artist’s impression.)
So what if you’re hitting the limitations of LINQ to SQL and want to move on to something better? Or what if you just want to try out an alternative ORM, but don’t want to have to build a whole new model from scratch just to try it out?
First things first: this is never going to be a completely transparent process. Every ORM has different conventions for defining units of work (LINQ DataContexts), setting up configuration, and so on. Having said that, LightSpeed 3 does include a handy new feature that should cut down on the workload.
If you drag a LINQ to SQL DBML file from Solution Explorer into a LightSpeed model, we’ll load your existing LINQ classes into the LightSpeed model. Easy as that! So you can easily keep your model, including any customisations and mappings; plus now you get all the benefits of the LightSpeed designer, like database synchronisation, and can start marking up your model with LightSpeed features such as eager load aggregates.
Here’s how it looks – the original LINQ to SQL model on the left, and the LightSpeed model on the right (click for full size):
A basic version of LINQ to SQL import is included in the LightSpeed 3.0 RTM. We’ve rounded out this feature a bit in the nightly builds, so if your LINQ model uses inheritance or access modifiers, you’ll want to get the updated version. As always, if you’re using a LINQ to SQL feature that the converter doesn’t handle, let us know and we’ll see what we can do.
The dynamic duo: LightSpeed & Azure
Recently there have been questions from LightSpeed users asking if LightSpeed works with Azure and the answer is YES!.

But wait a moment, what do we really mean when we talk about “Azure”? The brand has been used to describe a whole platform of cloud technologies from Microsoft so it is important to break down how LightSpeed works with each aspect. This is an important point to keep in mind when evaluating any product that claims to work with Azure by the way!
SQL Azure
SQL Azure is the database side of the fence. Many products can talk to SQL Azure quite happily because Microsoft made the smart move of using the SQL Server engine (with some modifications) rather than some hybrid new database type. This meant that we never had to actually make a change to LightSpeed to work with SQL Azure and because of that have been a bit slow to trumpet that LightSpeed worked happily with Azure.
Working against SQL Azure with LightSpeed really is just as simple as changing your connection string to point against your .database.windows.net host. Here is an example of running our LINQ unit tests for SQL Server against a local host:
and then against SQL Azure by changing the connection string:
The only difference is the latency involved, which reminds me not to run unit tests across the Internet again..
Windows Azure
Windows Azure can be thought of as where your application executes from – be it a website, a console application, whatever. This, interestingly enough, is the part where things can get a bit hairy for supporting the Azure platform. Windows Azure runs in two trust modes – Full Trust and Windows Azure Partial Trust (a cut down version of Medium Trust that you may have used before) and herein lies the only real challenge with supporting the Azure platform.
At the time of writing, the Microsoft documentation states that the default mode is Full Trust which is not actually correct. By default Azure will be setup to run in the Azure Partial Trust state and if you deploy a normal LightSpeed solution to it you’ll run into a problem. Now, you could set it to Full Trust, but that’s not ideal in all cases and we did some work a while back to ensure that LightSpeed happily supports Medium Trust environments.
If you wish to deploy into Windows Azure Partial Trust here’s a quick list of what to do:
1. Build your LightSpeedContext in code, do not use an app.config or web.config for the configuration.
2. Configure the LightSpeedContext to run in Partial Trust mode:
LightSpeedContext.UseMediumTrustCompatibility = true;
3. All properties on your entities need to read/write. You can enable this in the designer using the following property (click somewhere on the background, not on an entity):

That’s it! You’re good to deploy to Windows Azure in Partial Trust, LightSpeed will chat happily with SQL Azure as if they were old friends and you can kick back with a brew :)
Screencast: Getting started with LightSpeed
New to LightSpeed? New members joining your team and want them to up skill? Look no further than our updated “Getting started with LightSpeed” screencast.
This screencast is designed to help new users understand how they can install LightSpeed and then be working with their data and LightSpeed entities in ~10 minutes. If you’re an experienced LightSpeed user then there won’t be much to gain from this screencast but perhaps it will be helpful to share with those less experienced. You may also prefer some of our other screencasts :-)
In approximately 10 minutes you learn:
- How to create a new LightSpeed model
- How to configure a LightSpeedContext
- How to set up and use a strongly typed Unit Of Work
- How to undertake the 4 CRUD operations
- Bonus learning: That LightSpeed is the best choice for starting a project fast! :-)
The focus of LightSpeed has always been to get out of the way and let the developer actually get work done and we hope this video shows that.
We (and by “we” I mean “I” here ;) go through phases of putting together screencasts. If you have something you would like to see explained in true video glory then please drop a comment on this post and I’ll see what I can do. Suggestions do not have to be limited to our LightSpeed product – it can be for any of our products.
I hope that helps!
Querying enhancements in LINQ to LightSpeed 3
Tagged as LightSpeedThe highest-profile querying enhancements in LightSpeed 3 are obviously join and group support, but there are also a lot of other improvements that give you a bit more flexibility in your queries. In this post I’m going to give a quick tour of some of these.
Querying on aggregate values
LightSpeed now supports using aggregate values such as Sum or Count as part of your query criteria. Here’s a simple example:
var prolificContributors = from m in UnitOfWork.Members where m.Contributions.Count() > 8 select m;
You can also use selectors and functions within the aggregate:
var query = from m in UnitOfWork.Members where m.Contributions.Max(c => c.Title.Length) > 26 select m;
This also enables you to use Any and All over associations in a where clause:
var terseMembers = from m in UnitOfWork.Members where m.Comments.Any(ct => ct.Subject.Length <= 6) select m;
Contains support
You can use the Contains operator to perform a SQL IN query:
int[] memberIds = new int[] { 41, 43 }; var query = from c in UnitOfWork.Comments where memberIds.Contains(c.MemberId) select c;
Subselects
But wait, there’s more: the Contains operator also allows you to perform an IN query over a subquery: that is, you can write where some_query.Contains(some_attribute). Here’s an example:
var query = from m in UnitOfWork.Members where (from c in UnitOfWork.Comments where c.Subject.StartsWith("A") select c.MemberId).Contains(m.Id) select m.UserName;
The subquery selects all member IDs from Comments whose subjects start with “A”. The outer query then selects the user names of all Members whose IDs fall into the subquery. The subquery is passed to the database as a subselect of the outer query so this still all happens in one database query.
Querying over child collections
Sometimes you want to select a subset of associated entities, rather than the whole collection that you’d get if you simply referenced the association property. In LightSpeed 2, you could do this by querying on the foreign key of the associated entities, but LightSpeed 3 offers a Query overload that’s a bit more concise and intention-revealing:
var contribution1 = UnitOfWork.FindById<Contribution>(1); var commentsOnContribution1ByMember41 = from ct in contribution1.Query(c => c.Comments) where ct.MemberId == 41 select ct;
Note the use of
Query(c => c.Comments)
rather than the Comments collection itself. This produces a SQL query for only the selected Comment entities, rather than loading all the Comments on contribution1. This can be very handy if you’re dealing with very large child collections and don’t want to materialise large numbers of entities!
Smarter projections
We’ve extended the range of things you can use in projections (select clauses). In particular, aggregates over associations are available in projections and are translated to SQL and run on the server:
var query = from m in UnitOfWork.Members select new { m.Id, CanBeTerse = m.Comments.Any(ct => ct.Subject.Length <= 6) };
Combining operators
LightSpeed now offers basic support for the Intersect, Union and Concat operators, though these are available only for entity selections (not projections) and do not support eager load.
Custom function mapping
Want to call a SQL function from your LINQ query, but we don’t provide a translation from a CLR method, or worse still there’s no corresponding CLR method at all? Now you can create a custom function mapping that allows you to keep writing strongly-typed LINQ queries and having the desired function appear in the SQL translation. Find out how here.
And many more
We’ve also implemented many more minor enhancements, such as ordering on properties of value objects, improved handling of literal values, etc. Download the free edition and try it out today!
![]()
BrainDump (1)
Community Code (1)
Events (6)
General (27)
Lab Samples (2)
LightSpeed (112)
MegaPack (3)
News (37)
Products (51)
Projects (4)
Screencast (6)
Silverlight (1)
Silverlight Elements (1)
SimpleDB Management Tools (8)
Visual Studio (4)
VS File Explorer (4)
WPF (28)
WPF Diagramming (11)
WPF Elements (15)
WPF Property Grid (20)
![]()
February 2010
January 2010
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
December 2007
November 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007









Posted by Jason on 25 January 2010 




