Friday, January 29, 2010

Visual Studio 2010 beta 2

Visual studio difference between Silverlight Navigation application and Business application

Silverlight Business application adds login/logout support.

Using partial classes to spread a Domain Service across multiple files


You need a few extra methods in the Domain Service generated from the entity model, most often because you want to create selection methods with other criteria for filtering. You can add these in the Domain Service class. But if for some reason your entity model changes then the Domain Service needs to be regenerated too, causing all your custom code to disappear.


Create a partial class to spread a Domain Service across multiple files.
Modify the generated Domain Service class to partial, e.g.
public partial class NorthwindDomainService : LinqToEntitiesDomainService<northwindEntities>
Add a new class to the web project, with the same class name but with the extension 'partial.cs' instead of '.cs', e.g.
public partial class NorthwindDomainService : LinqToEntitiesDomainService<northwindEntities>
Add the using statements from the generated class to your custom class.
In case you need to regenerate the entity model and the class, you only have to add the word 'partial' to your generated Domain Service class. Your custom class will be kept as is.

Visual Studio 2010 Beta 2 DataGrid bug

Visual Studio 2010 Beta 2 has a little bug that when creating the DataGrid control it added subcontrols <controls:DatePicker in the "controls" namespace which is properly set to

xmlns:controls="clr-namespace:System.Windows.Controls; assembly=System.Windows.Controls"
but it didn't add a reference to the required library "c:\Program Files\Microsoft SDKs\Silverlight\v4.0\Libraries\Client\System.Windows.Controls.dll"
Add this reference manually.

Thursday, January 28, 2010

Silverlight application themes for Silverlight 4

I have used the silverlight application themes from Tim Heuer in the Visual Studio 2010 beta with Silverlight 4 and they work.

  • Put the Style.xaml that you downloaded from one of the themes in the Assets folder of your Silverlight project.
  • Overwrite the existing one.
  • In VS 2010 select the Style.xaml and change the property Copy to output directory into 'Copy always'.


Silverlight 4 WCF RIA Services Line of Business Application Hands-On Lab

In this 108 page hands-on lab you will learn how to use Beta 2 of Visual Studio 2010 and Beta 1 of Microsoft Silverlight 4 to create a data driven line of business style rich internet application that implements many of the new features that Silverlight 4 introduces. 

These features are implemented in the lab:

  • True multi-tier architecture.
  • Entity framework and service layer definition.
  • Data filtering, paging, sorting and grouping.
  • Data modification and validation.
  • Foreign key management.
  • Projections.
  • Programmatic printing from a Silverlight application.
  • COM interop with Microsoft Excel and running full-trust out-of-browser.

Great work from Sascha Corti and Ronnie Saurenmann!

Monday, January 04, 2010

Silverlight 3 How to display the version number of my silverlight assembly

On the About page of my silverlight 3 app I wanted to display the version number of the silverlight assembly (not of the web application).

In the Silverlight forums I found a simple solution by PBROMBERG:
Assuming that the xaml page contains a textblock txtVersion with no text.

Assembly asm = Assembly.GetExecutingAssembly();
string[] parts = asm.FullName.Split(',');
txtVersion.Text = parts[1];

the resulting version info will be displayed like: