SilverKeys Part 3

The UI (or should I say UX now?) is 90% complete (for this iteration that is) as the image below shows. There are a few bug fixes left to complete, plus I'd like to to some moderate re-factoring of both the 'business' logic and the XAML.

I'll post some of the more interesting aspects of the project in later posts and either make the source available from here or I might look at uploading to Codeplex et al so  others can go ahead and take it forward if it's found to be interesting. There also be a 'live' version available. I'll be using it personally to try out different keys & progressions for future compositions.

 

System.Windows.Markup.XamlParseException when using Tag property in Silverlight

Although MSDN says you can use the FrameworkElement.Tag Property to store an arbitary object, if you try to store anything other than a string you get a System.Windows.Markup.XamlParseException. It seems I'm not the only one to notice this.

A Silverlight Scale Chord Calculator (SilverKeys Part 1)

One hobby I have is music production (based around a Pro Tools LE 8 setup) and recently I've been learning some music theory. I have created a cheat sheet which is on my wall to assist with working out scale degrees, etc. Why do it by hand when a computer can do it for you, eh? Thought this would make a good Silverlight project as ideally I'd like to be able to visualise a chord on a piano keyboard or a guitar fretboard.

Functionality would be something like:

  • Choose a scale - Major or (natural) Minor;
  • Choose a scale root note (as a dropdown or better by directly interacting with piano keyboard);
  • Show all the notes in the scale (initially visualised on piano keyboard);
  • Show the scale degrees and chords for the given key;
  • Show the common chord progressions in the key;
Future additions:
  • Add guitar fretboard vis;
  • Add harmonic minor scales;
  • Add modal functionality;
  • Play sound samples of notes & chords;

The application will be a standalone client app, i.e. no WCF backend services, etc. It will be designed using TDD and using Expression Blend where appropriate (with the Blend service pack it extends the trial period to 60 days). As I can't think of a good name off the top of my head, i'll call the app SilverKeys...

System.ExecutionEngineException in Silverlight

Check your resource styles have specified a target type, e.g. TargetType="TextBlock": the exception that is thrown is System.ExecutionEngineException but with no inner exception details it doesn't offer much help. The solution will also build correctly without even a XAML warning...

Design Pattern for Silverlight 2

It seems the Model-View-ViewModel (MVVM) is the preferred pattern at present for implementing cleanly separated SL apps (& WPF client apps). Aims to increase testability and leverage data-binding in XAML to implement the View part of the pattern. The Model is responsible for accessing data (e.g. WCF service, REST, etc) and passing it to the ViewModel (which holds state and provides operations to the View)- the View then binds to objects in the ViewModel class. A view has a reference to a Model interface rather than a concrete implementation, this allows testing of the Model in isolation. We could implement the ViewModel as an interface or for testing purpose just build a stub Model and pass that the the ViewModel (going the whole hog you could use dependency injection such as Unity for Silverlight or Ninject to wire the parts together).

More info on MVVM:

http://jonas.follesoe.no/YouCardRevisitedImplementingTheViewModelPattern.aspx 

 http://msdn.microsoft.com/en-us/magazine/dd458800.aspx

http://www.nikhilk.net/Silverlight-ViewModel-Pattern.aspx 

 

 

Cannot find 'ServiceReferences.ClientConfig' in the .xap application package when running Silverlight unit tests

When using the browser-based Silverlight unit testing framework to test a SL app which contains service references you might get a Cannot find 'ServiceReferences.ClientConfig' in the .xap application package error. You cannot just add a deployment item to the current test config as SL tests don't seem to use this. A quick fix to this is to add a linked file to ServiceReferences.ClientConfig in your test project.

Unit Testing with Silverlight 2

It doesn't appear there is any VS IDE integrated support for running SL unit tests but there is a browser-based unit testrunner, 
 
To get the correct templates follow this straightforward guide:
 
 
Then just create your unit test project(s) and write tests using the same attributes as [TestClass] [TestMethod] etc.
 
To run your SL tests (they don't show in VSs Test View window) set you SL unit test project as Startup and run, a browser opens and runs the tests, detailed instructions at http://www.jeff.wilcox.name/2008/03/silverlight2-unit-testing/#option2

Imported posts not appearing in BlogEngine.NET

 If you've used the BlogEngine.NET import tool and your post are not showing you could try the following:

  http://mcgeown.co.uk/BlogEngine/post/2008/05/09/Force-BlogEngineNet-to-update-its-cache-after-an-import.aspx

 I recycled the IIS app pool and that seems to have flushed BEs cache.