Bloggers: Win a free place to the Silverlight Masterclass (worth £1095!)

bbits are giving away a free ticket for the Silverlight Masterclasses in June

To enter the raffle all you need to do is use the exact text between these lines in your blog post, including all the links, then email Ian@bbits.co.uk with the url to the blog entry.  You can chose any of the events listed on the site.

The draw will be made on June 1st and the winner notified by email and via this blog.

Good Luck!

-------------- TEXT STARTS HERE

The Silverlight Tour comes to the UK – and it’s called the Masterclass!

This 3 day hands-on training with both designer and developer tracks looks awesome and (uniquely) has two expert trainers per course. 

Currently scheduled in London, Manchester, and the Midlands for June, all courses also come with the chance to win an xbox 360, and Silverlight Spy licences!

Early bird discount of £100 if you book in May, and if you are a member of #SLUGUK or #nxtgenug there are additional discounts to be had.

Full Details are here: http://silverlightmasterclass.net

In addition bbits are holding a raffle for a free ticket for the masterclass. To be eligible to win the ticket (worth £1095!) you MUST paste this text, including all links, into your blog and email Ian@bbits.co.uk with the url to the blog entry.  The draw will be made on June 1st and the winner informed by email and on http://silverlightmasterclass.net

------------- TEXT ENDS

Cheers

Ian

Using the DataStateBehavior for “Loading animations” in MVVM

Behaviours are growing in importance within Blend – especially for developing Silverlight and WPF apps using the MVVM pattern.  In fact they are becoming so useful we have to wonder when they will be made available in the editor of VS 2010.

A couple you should definitely look at, if you haven’t already done so when using MVVM, are the CallMethodAction and InvokeCommandAction that make it easy to wire up a Method or Command in your ViewModel using the Blend editor.

However a new one that now ships in box with Blend 4 offers something a little more interesting and perhaps less obvious.  This is the DataStateBehavior which allows you to change to a Control State depending on a property of your ViewModel.  This struck me as an easy way to provide an animation when your ViewModel is doing some async work.

Lets take a simple example.  First the ViewModel.  This has a single method called DoWork that simulates a few seconds of work (e.g. calling an async service) and a property called IsWorking that can be set to true whenever the ViewModel is doing some prolonged work.  One way to handle this in a more complex scenarios when you could possible have multiple async calls happening is to have a counter that you increment whenever you start some work and the decrement when you stop work.  Whenever the counter is positive then you should display your “loading animation” which we’ll achieve through the DataStateBehavior.  Here it is:

   1: public class MainPageViewModel : INotifyPropertyChanged
   2: {
   3:  
   4:     private bool _isWorking;
   5:     public bool IsWorking
   6:     {
   7:         get
   8:         {
   9:             return _isWorking;
  10:         }
  11:         set
  12:         {
  13:             _isWorking = value;
  14:             RaisePropertyChanged("IsWorking");
  15:         }
  16:     }
  17:  
  18:     private int _workCount;
  19:     private int WorkCount
  20:     {
  21:         get
  22:         {
  23:             return _workCount;
  24:         }
  25:         set
  26:         {
  27:             if (value < 0) value = 0;
  28:             _workCount = value;
  29:             IsWorking = _workCount > 0;
  30:         }
  31:     }
  32:  
  33:     public void DoWork()
  34:     {
  35:         //simulate some work
  36:         WorkCount++;
  37:         DispatcherTimer timer = new DispatcherTimer();
  38:         timer.Interval = TimeSpan.FromSeconds(3);
  39:         timer.Start();
  40:         timer.Tick += (sender, args) =>
  41:         {
  42:             WorkCount--;
  43:             timer.Stop();
  44:         };
  45:         
  46:     }
  47:  
  48:     public void RaisePropertyChanged(string propertyName)
  49:     {
  50:         if (PropertyChanged != null)
  51:         {
  52:             PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
  53:         }
  54:     }
  55:  
  56:     public event PropertyChangedEventHandler PropertyChanged;
  57: }

 

In Blend I first set the DataContext for the User Control to this ViewModel

image

Which looks like this in Xaml and will instantiate the ViewModel and set it as the DataContext for this View (UserControl)

image

I drew a big button on the artboard and then created a couple of states called “Working” and “NotWorking”.  I had a bit of fun setting some effects and animations for the state transitions.  In particular I made sure the animation for the Working state was set to auto-reverse and repeat forever.

image

Now comes the fun bit by using Blend behaviours to wire up the click event on the button to the DoWork method in the ViewModel and then to use the DataStateBehavior to change between the Working and NoWorking states based on the IsWorking property on the ViewModel.

First to wire up the Do Work Method (Note there is also an InvokeCommandAction you can use if you have a command on your ViewModel rather than a simple method I have created here).  To do this you simple drag the CallMethodAction from the Behaviors section in the assets panel and set the properties as shown below:

image

To wire up the DataStateBehavior the process is similar – drag it from the behaviour from the assets panel and set the properties as shown:

image

This looks like this in XAML:

image

And that’s it!  Running the app and clicking the button will run your method in your ViewModel and dispay your Working state.  Once the work is complete in the ViewModel the control returns to the NotWorking state. 

This is nice because:

  • The ViewModel knows nothing of the View and so is more easily testable.
  • Everything can be wired up in Blend – no code to write for a designer.
  • The Xaml is actually nice and straight forward to, and easy to understand.

I would like to see Behaviours in the VS2010 too, because I think there is definitely a case for developers taking advantage of this sort of thing, though it wouldn’t take much for them to type in the Xaml directly.

Example project is available from here: http://cid-fb8b852ef1ab0b35.skydrive.live.com/self.aspx/SampleCode/SimpleMVVMLoadingAnimation.zip 

Cheers

Ian

P.S. Don’t forget our Silverlight Masterclass is now touring the UK:  Http://silverlightmasterclass.net – book early!

New Asp.Net MVC Training Course

We have just published our Asp.Net MVC course (http://bbits.co.uk/Services/Training/?63).  Although we have been providing MVC training within other courses for some while, and to clients directly, this now provides a full 5 day outline for learning MVC from the ground up.  Plus some insights into what is coming in version 2…

As always, any questions you have or customisations you would like to make to this course, let me know!

Cheers

Ian

Follow-up from Silverlight User Group Talk

Thanks everyone who attended my talk at the Silverlight User Group last night.  I really enjoyed myself and was glad to see a hearty discussion around RIA services – which is surely the point of these sorts of events; to get everyone thinking and get the dialog going.

You can download my presentations from here: http://bit.ly/SlugSep09IB 

Ria Services

 

If you want to find out more about Ria Services then Brad Adams is the person to go to – if you haven’t seen his blog series that followed on from his Mix09 series then check that out now; it consists of >20 posts covering everything from using a ViewModel,  azure, authentication, multiple clients and data sources, SEO, Unit testing and much more.  And it’s ongoing with promises of new posts on modular development (will be interesting to see how that relates to Prism).  He has a summary of the current posts here: http://blogs.msdn.com/brada/archive/2009/08/02/business-apps-example-for-silverlight-3-rtm-and-net-ria-services-july-update-summary.aspx.

SilverlightPulse.net

 

I have placed the app on http://silverlightpulse.codeplex.com/  - if you haven’t used codeplex before it is Microsoft’s Open source repository – you can use a range of clients such as svn, team system etc to work with the source.  I have published under the Microsoft Public License (Ms-PL) which is the most permissive Open Souce MS license as I understand it

Anyone who is interested in helping out please get in touch (Ian@bbits.co.uk) – it would be really great to take this app and make it a great showcase for members of the Silverlight User Group in the UK.  There are lots of things we could explore both functionally (eg wordle maps, integrating other network api’s such as friendfeed, using the silverlight bing map), and technically (using Prism for modularity seems like a great fit, having more server processing to aggregate data for all perhaps (instead of doing the work on the client), adopting MVVM,  are a few that come to mind.  I actually think this could develop into something really interesting and I am sure there will be many ideas from the community that could be used.  Get your thinking caps on and get in touch – please :-)

Cheers

Ian

 

I am talking at the UK Silverlight User Group tonight

I am chuffed to be talking at the user group meeting tonight, along with Ian Smith.

Details here

I will be talking about two things :

Silverlightpulse.net

This was the micro app I created before the Mix 09 conference in anticipation for the Silverlight 3 announcements and why I was originally invited to talk at the user group meeting (it’s a bit of a long story as to why it has taken so long for that to actually materialize – filled with stories of product launches and twisted ankles!). 

I still think this is a very interesting app though, and has some potential that I have yet to realize.  Tonight I will be going into why I think that and asking: “is this a worthwhile community project and who wants to be involved?”

Using RIA Services with Silverlight

To me RIA services offer a prescriptive pattern that will be useful for a majority of projects.  ScottGu called out 80% as the take-up figure when he talked about it recently and John Papa said in a recent tweet “I think RIA Services could be the best thing to happen to Silverlight LOB apps”.  I agree, though some may not entirely.  I only have an hour in total this evening but I hope to give a flavour of RIA services and what it can bring to the party.

Hope to see you there!

Cheers

Ian

Using the Zune HD in the UK

I recently picked up a couple of Zune HD’s while on a trip to the US.  There are plenty of reviews out there so this is not one of those, instead, and since the Zune HD has not been released in the UK yet, I thought it would be useful to outline how the device works in the UK.  So without further adieu, here are the burning questions that were on my mind as I played with the device on the flight back, and the answers both my son (who has the other one) and I discovered as we played with them yesterday.

Getting the Marketplace in the UK on the Desktop

Since the Zune HD is not available in the UK, there is no marketplace for UK users right?  Not quite, although it takes a bit of manipulation, and you can’t buy anything (though I have some thoughts on how to do that (read on…)!  However even without purchases there is still plenty of value in having the marketplace enabled because you get all the extra music discovery features of pictures, bios, discography and related music,and without the marketplace you can’t get the apps.

Initially I thought I would need to set this up in the US which is what I did, however on my return I managed to get the same result on my son’s laptop.

It’s pretty simple just set you regional settings in Windows to US before you start the Zune software and hey presto!

image

image

Setting you regional settings back to UK will give you the following Zune menu’s

 

image

If you want to download anything (such as the apps) you also seem to need to set up a Windows Live Id with a US location – this worked fine for me.

Getting the Marketplace on your Zune HD

If you ran the setup for your Zune HD before changing the O/S to US you will not get the marketplace on the device.  To sort this out you will need to re-install the software on the device while you have Windows set to US region.  You can reset the device (you won’t lose any content but it won’t be associated with your computer anymore) by turning it off, then holding down the Power and Media button (the one on the side) for 15 seconds.  More great tips like this are here by the way (anythingbutipod.com)

Buying things from Marketplace in the UK

You are not going to be able to buy anything from the marketplace unless you have a valid US credit card and address, which I guess is unlikely for most people (certainly me).  However I am wondering if you could buy points from Xbox live with a the Live ID account you created with a US address, or perhaps buy an Xbox Points card from a local store or Amazon and use that?  Haven’t tried that yet, but would be interested if anyone gets it to succeed?

Does the HD Radio work in the UK?

Yes it works fine as a normal FM radio though the stations that are found have strange four letter names (e.g. Radio 1 is CFJM Classical!).  When the station is playing the RDS name will come through and display on the screen as well as other program information if it is available, but the saved names is always the four letter one (even though I changed the settings > radio > to Europe). DAB is not going to work by the way.

DSC_6849 (Medium)

Any Other Questions?

If you are thinking of getting a Zune HD for use in the UK and have a question, feel free to ask me – I’d be happy to try it out on the device and let you know via this blog entry…

Cheers

Ian

Technorati Tags: ,

TDD Masterclass Free Draw – and the winner is….

Thanks for everyone who entered the competition for a free ticket for the TDD Masterclass with Roy Osherove, 21-25 September in Kent, UK.

We had lots of entries and all the names were printed out and put into a bowl and then the winner was picked out at random by my 6 year old daughter this evening:

DSC_6756

I am pleased to announce that the winner is : Sara Stephens!
http://developerdame.blogspot.com/2009/08/tdd-masterclass-in-uk-free-ticket.html

Congratulations to Sara!  Sara - I will send you a separate email with details of your free ticket ;-)  It promises to be a fantastic course!

Once again thank you everyone who supported this promotion.

If anyone would still like to come to the course there are still a few places left if you would like to come – please contact me directly if you are interested as soon as possible!

Cheers

Ian

Bloggers: Win a free place for Roy Osherove’s TDD Masterclass (worth £2395!)

bbits are giving away a free ticket for Roy Osherove’s TDD Masterclass in September in the uk.

To enter the raffle all you need to do is use the exact text between these lines in your blog post, including all the links, then email Ian@bbits.co.uk with the url to the blog entry.

The draw will be made on September 1st and the winner notified by email and via this blog.

Good Luck!

-------------- TEXT STARTS HERE

Roy Osherove is giving an hands-on TDD Masterclass in the UK, September 21-25. Roy is author of "The Art of Unit Testing" (http://www.artofunittesting.com/), a leading tdd & unit testing book; he maintains a blog at http://iserializable.com (which amoung other things has critiqued tests written by Microsoft for asp.net MVC - check out the testreviews category) and has recently been on the Scott Hanselman podcast (http://bit.ly/psgYO) where he educated Scott on best practices in Unit Testing techniques. For a further insight into Roy's style, be sure to also check out Roy's talk at the recent Norwegian Developer's Conference (http://bit.ly/NuJVa). 

Full Details here: http://bbits.co.uk/tddmasterclass

bbits are holding a raffle for a free ticket for the event. To be eligible to win the ticket (worth £2395!) you MUST paste this text, including all links, into your blog and email Ian@bbits.co.uk with the url to the blog entry.  The draw will be made on September 1st and the winner informed by email and on bbits.co.uk/blog

------------- TEXT ENDS

Cheers

Ian

New Silverlight 3 Training in the UK

bbits have produced 2 new Silverlight 3 courses; one targeted at designers, the other at developers building line of business applications.

Both are bang up to date, including Sketchflow and Blend 3 for designers and RIA Services, PRISM and M-V-VM for developers.

Take a look:

bbits courses can be customised at no extra cost, so if you can’t take the 5 days for the full developers course, you can cherry pick the bits you want and just do them!

Cheers

Ian

Technorati Tags: ,,

Learning TDD by looking at other peoples tests

Roy Osherove is a leading expert in TDD – he had a brilliant podcast with Scott Hanselman recently and his blog makes for in-depth reading on TDD and Unit Testing.  In particular check out the Test Reviews of publically released Unit Tests – including nerddiner, MVC, and Unity.  This gives a much needed real world critique of tests that people are actually writing – in my experience developers find this sort of thing very informative and helpful.  I would recommend spending some time watching these if you are at all interested in TDD (as more and more developers are…)

As a sample what is wrong with the following test:

image

If you got the fact that the EventDate will change every time you run the test, that’s good, but there are quite a few other problems here that Roy highlights – I’ll leave it up to you to watch the video and find out for yourself!

 

Cheers

Ian

Technorati Tags:

Disclosure:  bbits are hosting a TDD masterclass with Roy from September 21-25 here in the UK.  Every delegate gets hands-on tutoring from Roy himself, together with a copy of his book, The Art of Unit Testing and other goodies.  Spaces are strictly limited to 20 delegates, and there are a few early bird discounts available if you are quick here:  http://amiando.com/TDDMasterclass ;-)

«September»
SunMonTueWedThuFriSat
2930311234
567891011
12131415161718
19202122232425
262728293012
3456789