As I thought this is a question that could interest many people, instead of answering this question directly in the Prism codeplex forum I decided to create a short blog post and answer it here.

The answer is “kind of”. Silverlight 4 Beta, so far, only supports binding commands to controls that inherit from ButtonBase (Button and HyperlinkButton), as you can read in Tim’s and Mike’s posts.
Therefore, if you are using Prism, these are the things that you will not need any more, and those that you will:

No longer necessary

ButtonBaseCommandBehavior and Click classes from the CompositePresentationSilverlight assembly. As these are used to hook the command and the click event through XAML, you can bypass this by using the new command support.
<Button Content=SaveCommand={Binding Path=SaveOrderCommand}/>

Still necessary

As there is not an actual implementation of the ICommand interface, the DelegateCommand and CompositeCommand are still useful. Also, as controls other than Buttons do not have the possibility to bind their events to commands in the ViewModel, using attached behaviors is a good approach. You can use this code snippet to simplify the work.

Wrapping up

I hope this helps clarify this topic a bit, and if you have any doubts drop by the Codeplex forum and ask away (if you are shy you can always leave me a comment).

In case you want a working sample, I have made a couple of changes to the Commanding Quickstart to use the Command property instead of Prism’s attached behavior. You can find it here. The code is provided “AS IS” with no warranties and confers no rights.

Shout it

kick it on DotNetKicks.com

Most of you know that a Silverlight 4 Beta was released last Wednesday, after Scott Gu’s PDC keynote. If you are a Prism user, and if you are reading this there’s a high chance you are, you are probably wondering how this relates to p&p future plans. Well, Blaine has given us a brief idea of Prism’s future in this forum thread, so you might want to check it out.

On a related but different subject Fernando and I migrated the latest Prism release to Silverlight 4 Beta version & Net 4.0. A few minor changes needed to be done in the code (explained here), and some other in the .csproj files due to an issue we came up using the Silverlight migration wizard.

Migration Issues

After going through the migration wizard, you will notice that all Silverlight projects are not loaded. This is because they are still looking for the 3.0 installation directory instead of 4.0 as you can see in the picture below.

image

To fix this issue you need to edit your .csproj file and redirect it to the Silverlight 4 directory. The line that is related to this issue is the following:

<Import Project=$(MSBuildExtensionsPath32)\Microsoft\Silverlight\$(SilverlightVersion)
\Microsoft.Silverlight.CSharp.targets/>

Here you have two options:

  1. Replace “$(SilverlightVersion)” for “v4.0″.
  2. Modify any existing declarations of “SilverlightVersion“ in your file and update them to 4.0. Take into account that some of them might be using the “FrameworkVersion”. The code below shows this situation:
    <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
    <SilverlightVersion>$(TargetFrameworkVersion)</SilverlightVersion>

Prism Migrated Download

If you want to save some time, you can download the CAL, Quickstarts and RI from here. The code is provided “AS IS” with no warranties and confers no rights and is shipped under the “works on our machine” license.

Have fun coding in Silverlight 4!!!

Shout it

kick it on DotNetKicks.com