2014 – Happy New Year!

Now that 2013 has come to an end and I’d like to thank everyone who has been in touch, or has supported me during the past 12 months.

I wish everyone the best of luck for 2014, and I hope that you’re successful in achieving your ambitions, dreams, and New Year resolutions.

Posted in Uncategorised | 2 Comments

MSDN Flash articles on LightSwitch

Over the past year or so, I’ve contributed various articles to MSDN Flash on the topic of LightSwitch. The nice thing about MSDN Flash is that it reaches a large developer audience. Many of its readers are not LightSwitch developers, so it’s a great way to introduce the technology to those that are unfamiliar. Earlier this year, I wrote about the new LightSwitch features in VS11.


My latest article went out last week and talks about the new HTML Client in the upcoming version of LightSwitch. This major new enhancement makes it easy to target your LightSwitch application at mobile devices. You can see more of what I’ve written through the following link.


Posted in LightSwitch | Leave a comment

LightSwitch – MSDN Article with Garth Henderson

The MSDN flash article that I’ve been working on with Garth was published last week.

In terms of LightSwitch, Garth is one of most talented individuals that I know. For me, it’s been pleasure finding out and seeing the projects that he’s worked on.

You can find out more by visiting the following link.


Posted in LightSwitch | Leave a comment

LightSwitch – Automatically Upper Case TextBox Text

Here’s a quick post in reference to question on how to automatically upper case the characters whilst typing into a TextBox.

LightSwitch includes a changed event but the problem with using this is that it only fires after leaving the TextBox. You therefore don’t see the characters being upper cased as you type into the control.

One possible workaround is to handle the KeyUp event of the TextBox control. In keeping with the standard practice of handling Silverlight control events, the ControlAvailable event is used to attach the KeyUp event of the Textbox.

Assuming that you have a TextBox named ‘Surname’, here is some sample code that automatically upper cases the characters as you type into the control. The ‘SelectionStart’ property is used to set the cursor location to the end of the TextBox, otherwise you end up with some strange behaviour as subsequent text will be inserted into the start of the TextBox.


Private Sub MyScreen_Activated()
    AddHandler Me.FindControl("Surname").ControlAvailable, AddressOf TextBoxAvailable
End Sub

Private Sub TextBoxAvailable(sender As Object, e As ControlAvailableEventArgs)
    AddHandler CType(e.Control, System.Windows.Controls.TextBox).KeyUp, AddressOf TextBoxKeyUp
End Sub

Private Sub TextBoxKeyUp(sender As Object, e As System.Windows.RoutedEventArgs)
    Dim strTextUpper As String = CType(sender, System.Windows.Controls.TextBox).Text.ToUpper
    CType(sender, System.Windows.Controls.TextBox).Text = strTextUpper
    CType(sender, System.Windows.Controls.TextBox).SelectionStart = strTextUpper.Length
End Sub

Here’s the C# version.


private void CreateNew_Activated()
    this.FindControl("Property1").ControlAvailable += TextBoxAvailable;

private void TextBoxAvailable(object sender, ControlAvailableEventArgs e)
    ((System.Windows.Controls.TextBox)e.Control).KeyUp += TextBoxKeyUp;

private void TextBoxKeyUp(object sender, System.Windows.RoutedEventArgs e)
    string strTextUpper = ((System.Windows.Controls.TextBox)sender).Text.ToUpper;
    ((System.Windows.Controls.TextBox)sender).Text = strTextUpper;
    ((System.Windows.Controls.TextBox)sender).SelectionStart = strTextUpper.Length;
Posted in LightSwitch | 2 Comments

LightSwitch – Extension Development Kit

Earlier this week, Yann Duran mentioned the Extensibility Toolkit which was featured in Beth Massi’s recent video.


For those who haven’t watched this, the following post contains some screenshots from the video illustrating how this works. (I would still recommend watching the video however. The toolkit section appears at 55min).

The toolkit goes a long way to simplifying the creation of extensions. The current method of creating extensions using the “Cookbook” is fairly time consuming. In particular, the errors that could be encountered when renaming everything from “BlankExtension” can be very painful.



With the Extension Library installed, opening Visual Studio and selecting “New Project” shows the following Extension templates.



Creating a new project based upon the above template creates a solution with the following projects.



The above projects correspond to the projects in a regular LightSwitch project (for example Client, Common, Server, etc) You will notice 2 additional project which are the “Vsix” and “Lspkg” projects. The output from the Vsix project will be used to install the completed extension into Visual Studio.

LSPKG stands for “LightSwitch Packaging Project”. Right clicking on this and choosing “New Item” brings up the following screen.


From here, templates relating to the 6 LightSwitch Extensibility points are available.

  • Business Types
  • Custom Controls
  • Data Source
  • Screen Template
  • Shell
  • Theme

Selecting the “Theme” option will create a theme which includes all the display elements. You can simply modify the fonts and colours to suit your style.



Although this toolkit has not yet been released, it should hopefully simplify the creation of extensions to a very large degree.

Posted in LightSwitch | 4 Comments

Microsoft Community Contributor Award 2011

Today, I received an email awarding me a Microsoft Community Award for 2011.



In all honesty, I knew very little about this award until today and still don’t know who nominated me nor what was involved in me being awarded this prize.

I’m very grateful to those who were influential in this process. In particular, I’d like to thank all my friends at Microsoft UK and I also want to give a special mention to everyone in the Microsoft LightSwitch team who are currently doing a spectacular job.

Posted in Other | 11 Comments

Behaviour Driven Design with Ian Cooper

During this months user group meeting in Reading, Ian Cooper presented a session on Behaviour Driven Design.

Much was covered during the event but some of the main points whichI took away were:

  • Reducing rework is one of the key principles of BDD
  • This is achieved by fully testing and involving the customer during each iteration
  • Analysis of typical applications reveal that 45% of features are never used. 7% of features are regularly used. There is much inefficiency is software as a large percentage of features are never used.
  • ‘5 Whys’ – recursively asking why something is required 5 times can often reveal the real purpose of a requirement
  • The ‘Purpose Alignment Model’ can be used to work out features which add the most business value. This comprises of a chart with ‘Market Differentiation’ on the y-axis and ‘Mission Criticality’ on the x-axis. By using this to understand the purpose of a project, we stand a much greater chance of achieving the objectives.

Various tools such as Fit, Cucumber and Nbehave, Nunit, Mspec were also discussed.

I found Ian’s presentation very useful and so did many in the audience judging by some of the questions. Thanks for presenting Ian!

Posted in VBUG | Leave a comment

LightSwitch – Installing on Windows XP requires SP3

This might be relevant to those building Virtual PCs or those who are planning on testing using Windows XP. Contrary to the system requirements that are specified on the LightSwitch website, the minimum version of XP required is in fact SP3, and not SP2. The following error is returned if you attempt to install LightSwitch on XP SP2.

image  image
Illustration of what happens when installing under XP SP2.

Posted in LightSwitch | Leave a comment

Clearing Browser History now clears Flash Cookies in Version 10.3

After attending a security presentation this week, one thing I learnt is that clearing your internet browser history will now clear Flash cookies if you have the latest version of Flash installed. This was also reported through the IE blog last week.


In previous versions of Flash, the only way of clearing cookies was to use the Adobe ‘Settings Manager’ via the following web site.


The security risk this posed was that even after deleting your browser history, someone using your PC could partially trace your browsing history and the videos that you’ve viewed using Flash cookies or the ‘Settings Manager’ shown above. Websites were also using Flash cookies to restore ‘regular HTTP cookies’ which may have been intentionally deleted by the user.

This update appears to have been long overdue and is a very positive change in terms of improving browser privacy.

Posted in Uncategorised | Leave a comment

LightSwitch – Limiting Item Selections using a ComboBox

Overview of Article

One of the annoyances about the LightSwitch AutoCompleteBox is that there isn’t an option to limit selections to only those items which are shown in the list. Non existent values can be typed in, causing validation errors to occur when a screen is saved.


Fig 1 – Illustration of AutoCompleteBox failing to limit selections.

Fortunately, the Silverlight ComboBox control can limit items to the list and the following article describes how we can use this control on a LightSwitch screen.

In the following example, we’ll create a customer entry screen and allow the user to select from a list of available Countries.



The example solution contains a Person table and a Country table. The table schemas and relationships are illustrated in the following images below.

Fig 2 – Illustration of Person table

Fig 3 – Illustration of Country table


Fig 4 – One to Many relationship between Country and Person 



The following section describes the creation of the screens in the project..

  1. First of all, create an ‘Editable Grid Screen’ on the Country table to enable some Countries to be added.
  2. Create a ‘New Data Screen’ on the Person table.
  3. By default, an ‘AutoCompleteBox’ is created on the Country field. Change this to ‘Custom Control’ using the drop down list to the left of the control. After doing so, bring up the properties of the control and click on the ‘Change…’ link next to the ‘Custom Control’ field. In the dialog that appears, select the ‘ComboBox’ control from within the System.Windows.Controls namespace.

    image  image
    Fig 5 – Changing the AutoCompleteBox to a ComboBox

  4. We now need to create a data source in order to populate our ComboBox with a list of available Countries. In order to do this, click on the ‘Add Data Item’ button, select the ‘Query’ radio button and select ‘Countries – Country (All)’. Retain the default name of ‘Countries’.

    Fig 6 – Creating a data source for our ComboBox

  5. We now need to write some code to bind our ComboBox to the person entity. Click on ‘Write Code’ button and select the ‘_Activated’ event. Now write the following code:
  6. Private Sub CreateNewPerson_Activated()
        Dim comboControl As IContentItemProxy = Me.FindControl("Country")
        comboControl.SetBinding(System.Windows.Controls.ComboBox.ItemsSourceProperty, "Screen.Countries", Windows.Data.BindingMode.TwoWay)
        comboControl.SetBinding(System.Windows.Controls.ComboBox.SelectedItemProperty, "Screen.PersonProperty.Country", Windows.Data.BindingMode.TwoWay)
    End Sub

    Here’s the C# equivalent…

    private void CreateNewPerson_Activated()
        IContentItemProxy comboControl = this.FindControl("Country");
        comboControl.SetBinding(System.Windows.Controls.ComboBox.ItemsSourceProperty, "Screen.Countries", System.Windows.Data.BindingMode.TwoWay);
        comboControl.SetBinding(System.Windows.Controls.ComboBox.SelectedItemProperty, "Screen.PersonProperty.Country", System.Windows.Data.BindingMode.TwoWay);
  7. Now run our application and open the ‘Create Person’ screen. The list of Countries is now limited to those shown in the list.
    Fig 7 – Illustration of final screen showing the ComboBox which can not be typed into.


This article demonstrates how we can limit drop down choices by using a Silverlight ComboBox. It also illustrates the data binding syntax which is used when binding custom controls. The image below illustrates the relationship between the designer and the call to the SetBinding method. This is particularly relevant when creating a ‘details screen’ as the default entity will be ‘Person’ rather than ‘PersonProperty’.



Fig 8 – Illustration of DataBinding Code


Posted in LightSwitch | 22 Comments