I’m talking about WP7 at the UK Silverlight Group – 21 July

I am presenting on Windows Phone 7 at the next SLUGUK meeting – should be fun.  Rich Griffin will be joining me and we are expecting to have a real device or two to show off.

Details are here: http://consultingblogs.emc.com/markmann/archive/2010/07/07/silverlight-uk-user-group-july-2010-agenda.aspx 

Hope you can make it!

Cheers

Ian

Posted in Silverlight, Silverlight User Group UK (SLUGUK), WP7 | Tagged , , | Leave a comment

Silverlight Masterclass Blog Entry Winner! – UPDATE

UPDATE:

Unfortunately Alexsandar can’t make the course because he is based in Serbia and cannot get to the UK for these dates.  So we redrew the competition and the winner (for the second time) is Gary Pretty – congrats to Gary!

—————————————————————————

We had lots of entries for the Silverlight Masterclass Blog Entries competition – many thanks all of you who entered.

The Silverlight Masterclass is running in Birmingham July 28-30 with both designer and developer tracks.  Full details here: http://silverlightmasterclass.net

Yesterday we put all the names in sequence then used random.org to pick the lucky winner… and the winner is Aleksandar Panov  – congratulations to Aleksandar and we look forward to greeting you on the course.

Note:  If for any reason Aleksandar can’t make the class then we will make redraw to ensure there is still a winner.

Cheers

Ian

Posted in Uncategorized | Leave a comment

Silverlight Masterclass Bloggers Competition Extended

We are extending the date for the bloggers competition – it will now be draw on July 1st for the masterclass at the end of July so if you haven’t blogged yet have a go and enter the competition!

Details of the competition are here: http://silverlightforbusiness.net/2010/04/27/bloggers-win-a-free-place-to-the-silverlight-masterclass-worth/

Details of the masterclass: http://silverlightmasterclass.net

Cheers

Ian

Posted in Uncategorized | Leave a comment

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

Posted in Blend 4, Designers, Developers, M-V-VM, PRISM, RIA Services, Silverlight | Tagged , , , , | 4 Comments

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!

Posted in Blend 4, Designers, Developers, M-V-VM, Silverlight | Tagged , , , | Leave a comment

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

 

Posted in RIA Services, Silverlight User Group UK (SLUGUK) | 2 Comments

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

Posted in RIA Services, Silverlight | Leave a comment

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

Posted in Uncategorized | Leave a comment

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

Posted in TDD, Unit Tests | Leave a comment

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: ,,
Posted in Blend 3, Designers, Developers, M-V-VM, PRISM, RIA Services, Sketchflow, Training | Leave a comment