Xna 4.0 Game Development by Example: Beginner’s Guide

XNA 4.0 Game Development By Example authored by Kurt Jaegers is an excellent book for anyone who wants to learn XNA 4.0 games development. As you work through the book you develop some games including Flood Control, Astroid Belt Assault, Robot Rampage, and Gemstone Hunter.

This book comes in two versions one for Visual Basic .NET programmers, and the other for C# programmers. The good thing about this book is that it is very easy to read, and the examples are easy to follow. For anyone new to games programming this is a good place to start

Silverlight UserControl Binding to Object Properties

On your main user control create a member variable for your object. Your object will need to implement the INotifyPropertyChanged interface. In your constructor, set the data context to the member variable. Your child user control will need to provide a dependency property and implement the INotifyPropertyChanged interface. Place your child user control on to the main user control, and set its binding in XAML to the name of the property, and set its mode to two way: Text="{Binding MyDataProperty, Mode="TwoWay}".

Silverlight UserControl Type Not Defined Exception

I have had a really frustrating day and a half trying to get a Silverlight UserControl to work in another project of mine. The solution consists of an ASP.NET website with domainservices made available to a number of Silverlight applications. The Silverlight UserControl was properly namespaced, inline with all the other projects. But could I add it to my Silverlight applications. NO!

I knew it had to be something to do with namespace issues, and I tried all sorts. In the end I managed to solve the issue with the help of my senior colleague.

The solution was as follows.

Here are the original namespaces of the web host project, and the UserControl respectively:

  • Lucid.Online.Assessments.Server (the web host)
  • Lucid.Controls.Silverlight.BlockButton (the user control)

Here are the modified namespaces:

  • LucidOnline.Assessments.Server (the web host)
  • Lucid.Controls.Silverlight.BlockButton (the user control)

Just one period caused all that hassle! Why? I don’t understand why. But at least this has fixed my issue.

So if you get the Type ” undefined exception, just check your namespaces.

Silverlight with WCF Services and SQL LocalDB Development and Deployment using CassiniDev.

Problem: You are required to deploy a Silverlight application that accesses a database via WCF Services onto a standalone computer that does not have IIS, IIS Express, or SQL Server Express installed.  Your end users are people with very limited or no real technical background that find even simple day-to-day IT tasks difficult. What database and web server do you use, and how can you make the installation as easy as possible for your end users with little, or preferably no configuration?


  • Install SQL Server 2012 or higher on your development computer.
  • Connect to the LocalDb server instance in management studio using: (localdb)\v11.0.
  • Create a new query and enter the following command to create     your database:

    create database databaseName on (name=’databaseName’, filename=’fileLocation\fileName.mdf’)

  • Create your tables.
  • Create a new Visual Studio Silverlight with WCF RIA Services project.
  • Right click on the web project and select Manage NuGet Packages…
  • Select the online option and type entityframework.
  • Install EntityFramework.
  • Add a model.  The server name should be: (localdb)\v11.0.
  • Build your project.
  • Create your domain service.
  • Build your project.
  • In your Silverlight application import the System.ServiceModel.DomainServices.Client namespace, and the namespace of your web project.
  • Create a member variable for your domain context and IEnumerable of your domain object.
  • In the appropriate method that will instantiate the domain service add the relevant EntityQuery and LoadOperation lines of code.
  • Add you method that will handle the LoadOperation.Completed event, check that args is not nothing.
  • Use your entities as required.
  • Now add a Windows Form application.
  • Download and install CassiniDev.
  • In your Windows Forms application add a reference to the CassiniDev4-lib.dll.
  • For the tutorial on Using CassiniDev to host ASP.NET in your application.
  • Build your solution.
  • Copy the deployable portions of the web project into the WebContent folder located in the Windows Forms executable’s root folder.

On the client computer that you are going to deploy the solution on you will need to install:

  • Silverlight 5;
  • the .NET Framework 4.02 update (NDP40-KB2544514-x86-x64.exe);
  • and the SQL Server Local Database (SqlLocalDB.msi).

There is the Express Edition of InstallShield which is free to use.  Use this to create a Basic MSI project that will silently install the above components, and copy your application onto the client computer.  Create a desktop shortcut.  Run the executable from the shortcut to test that the application is working.

Update WPF UI During Method Execution

Samuel Jack of Seaturtle Software Limited has produced an interesting method that allows you to force the WPF UI to update during a method call. Here is the code:

void AllowUIToUpdate() {
DispatcherFrame frame = new DispatcherFrame();
Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Render, new DispatcherOperationCallback(delegate(object parameter)
frame.Continue = false;
return null;
}), null);

This code help me to fix an issue that I had with my WPF program. The original article is called Forcing Update of UI before my function exits.

Windows Forms Element Host Fails To Display WPF User Control

Today I had the situation whereby my Windows Form would not display a WPF User Control within its Element Host Control. The source of the problem was that my WinForms project was set to target the .NET Framework 4 Client Profile. The solution was to change the setting under the compile options for the project to .NET Framework 4. Everything now works fine, although you may need to delete forms and user controls and recreate them against the new target framework.

Build a Website in Visual Studio 2010 ASP.NET, C#, and MVC3.

To build a website using Visual Studio 2010 is very straight forward. You can can powerful results for very little coding effort. This article provides the steps for building a website using Visual Studio 2010 Professional, ASP.NET 4.0, C# 2010, MVC3, and SQL Server 2008 R2 Express Edition.

If you are a student, you can obtain Visual Studio 2010 Professional for free by visiting www.dreamspark.com. SQL Server 2008 R2 Express can be obtained by visiting  Microsoft.  Make sure these are installed before continuing with this article. Also, you will need to make sure the instance .\SQLEXPRESS is up and running.

Create an empty database. Open up the Visual Studio 2010 Command Prompt, and type aspnet_regsql. Go through the wizard that pops up to add the Membership API tables to the database.

Create a new Visual Studio 2010 C# ASP.NET MVC3 Website. Change the connection string in the Web.config file by appending the attribute “MultipleActiveResultSets=True” to the end of it. I have called my database Hospital, and the connection string is: "Data Source=.\SQLEXPRESS;Initial Catalog=Hospital;Integrated Security=True;Pooling=False;MultipleActiveResultSets=True;".

Open up the Package Manager Console. Type Install-Package MvcScaffolding. This will install the MvcScaffolding libraries necessary for the next steps.

In the Models folder of your Visual Studio project, add a class and call it HospitalModels. Add the following code:

namespace Hospital.Models
public class Specialism
public int Id { get; set; }
public string Name { get; set; }

The above code is a model. In this scenario it is a medical specialism. In the Package Manager Console type Scaffold Controller Specialism. Once scaffolding has been completed, you should see under Views a folder called Specialism, and the following CSHTML files: _CreateOrEdit.cshtml, Create.cshtml, Delete.cshtml, Details.cshtml, Edit.cshtml, and Index.cshtml.

In order for the created pages to be visual accessible via the home page, you need to modify the “_Layout.cshtml” file under the “Views\Shared” folder. Add the following code under the “About” menu item:

<li>@Html.ActionLink("Specialism", "Index", "Specialism")</li>

The first item in the ActionLink is the text that appears as the hyperlink, the second item is the page to display, and the third item is the folder which contains the required file.

Now you are able to run the project. If you have problems running the project, check your connection string and check the instance of SQL Server Express is running.

Hospital specialisms that you can use as sample data: Audiology, Cardiology, Colorectal, Cosmetic Surgery, Dermatology, “Ears, Nose & Throat”, Gastroenterology, General Medicine, Gynaecology (Women’s Health), Infertility Clinic, Joint and Muscle Clinic, Neurology, Obstetric Scanning, Opthalmology, Othorpaedics, Paediatrics, Pain Management, Physiotherapy, Podiatry, Psychological Medicine, Radiology, Respiratory Medicine, Rheumatology, Sexual Health Medicine, Shockwave Therapy, Travel Clinic, Urology, Varicose Veines, and Vasectomy.

You should be able to add, edit, delete, list all items, and view individual items, and all for little coding effort.