| Comments

Well, PDC09 is over and it was a blast.  What a relief it is to finally be able to show the world what the Silverlight team has been working on since Silverlight 3.  Based on the feedback at the conference, people are excited to dig into the new bits and start building solutions. 

As a round-up of resources from PDC, I’m putting some of my favorites here.

Video Content

For some of the PDC09 key Silverlight sessions, these are what I recommend:

  • CL01 – Microsoft Silverlight 4 Overview (Karen Corby)
  • CL02 – Silverlight 3 Advanced Performance and Profiling (Seema Ramchandani)
  • CL06 – Networking and Web Services (Yavor Georgiev)
  • CL07 – Mastering WCF RIA Services (Dinesh Kulkarni)
  • CL19 – Building Line of Business Applications with Silverlight 4 (David Poll)
  • CL20 – Improving and Extending the Sandbox with Silverlight 4 (Joe Stegman)
  • CL21 – Building Line of Business Applications with Silverlight and RIA Services (Brad Abrams)
  • CL22 – Advanced Topics for Building Large-scale Applications with Silverlight (John Papa)
  • CL24 – XAML Futures in Microsoft .NET Framework (Rob Relyea)
  • CL32 – Developing Testable Silverlight Applications (Keith Jones)
  • CL08 – Custom Behaviors for Advanced Microsoft Silverlight UI Effects (Peter Blois)
  • CL36 – Deep Dive on Bing maps Silverlight Control (Keith Kinnan)
  • PR03 – Integrate Microsoft Silverlight with SharePoint 2010 (Paul Stubbs)
  • FT24 – Building Extensible RIAs with Managed Extensibility Framework (Glenn Block)

These would be my “not miss” ones for Silverlight.  To help you get the videos faster, I’ve cooked up a few helpful links:

  • WMV Podcast RSS Feed (for Zune or other WMV players) – this is the WMV hi-res videos
  • iTunes/iPod Podcast RSS Feed – this is MP4 format so you can use it for any MP4 player.  As of the writing of this post, the MP4 encoding wasn’t done yet, but if you subscribe here you’ll get them when they are.
  • Windows Media Center playlist – want the 10-foot experience?  Here’s a set of playlist files for Windows Media Center.  Unzip the folder in your Public Videos folder for Media Center (or wherever you have your video content discoverable).  These point to the same hi-res videos that you would watch online.

I hope that helps get the most out of the video content for Silverlight.

Blog Content

There was some great blogging going on in the flurry of PDC and Silverlight 4 announcements as well.  Here are some I wanted to ensure you saw:

These were some of the highlights I wanted to call out.

Learning Resources

In case you missed the links in my guide post to Silverlight 4, there are 17 videos and code downloads that were launched for Silverlight 4.  In addition here’s some other resources:

Hopefully this should all get you started.  PDC was great.  Launching Silverlight 4 beta was awesome and I was able to talk to a lot of folks and get even more feedback for our requested features and what people are thinking about them.  Trust me your feedback will make it’s way back to the overall Silverlight team to see how people are using and planning to use the new features!

| Comments

One of the cool things I came across the in the October 2009 Silverlight Toolkit release was the addition of drag-n-drop targets for some of the core controls.  Now I know you are thinking great, another drag-n-drop useless control?!? and you’d be wrong.  I’m talking about things that make it easy to do do things like moving items from one list box to another, without writing code, but with it actually doing what you expect.

Let’s take the simplest example here: ListBox and moving items from one to another.  Using Expression Blend I’ve set up my XAML to be like this:

   1: <StackPanel Orientation="Horizontal" Margin="10">
   2:     <ListBox Width="200" Height="500" x:Name="FromBox" DisplayMemberPath="FullName"/>
   3:     <ListBox Width="200" Height="500" x:Name="ToBox" DisplayMemberPath="FullName"/>
   4: </StackPanel>

Behind the scenes I have a simple class which returns an ObservableCollection<Person> and binds the results to my FromBox.  Here’s the full simple class:

   1: using System.Collections.ObjectModel;
   3: namespace SilverlightApplication105
   4: {
   5:     public class People
   6:     {
   7:         public static ObservableCollection<Person> GetListOfPeople()
   8:         {
   9:             ObservableCollection<Person> ppl = new ObservableCollection<Person>();
  10:             for (int i = 0; i < 15; i++)
  11:             {
  12:                 Person p = new Person() { Firstname = "First " + i.ToString(), Lastname = "Last " + i.ToString() };
  13:                 ppl.Add(p);
  14:             }
  15:             return ppl;
  16:         }
  17:     }
  19:     public class Person
  20:     {
  21:         public string Firstname { get; set; }
  22:         public string Lastname { get; set; }
  23:         public string FullName
  24:         {
  25:             get
  26:             {
  27:                 return string.Concat(Firstname, " ", Lastname);
  28:             }
  29:         }
  30:     }
  31: }

And the code for my MainPage.xaml.cs:

   1: using System.Windows;
   2: using System.Windows.Controls;
   4: namespace SilverlightApplication105
   5: {
   6:     public partial class MainPage : UserControl
   7:     {
   8:         public MainPage()
   9:         {
  10:             InitializeComponent();
  11:             Loaded += new RoutedEventHandler(MainPage_Loaded);
  12:         }
  14:         void MainPage_Loaded(object sender, RoutedEventArgs e)
  15:         {
  16:             FromBox.ItemsSource = People.GetListOfPeople();
  17:         }
  18:     }
  19: }

Now I want to be able to drag an item from my FromBox to my ToBox.  I could do this in code, managing my index and moving things around, etc.  Or I can use something new from the toolkit!  Adding a reference in my Silverlight application to System.Windows.Controls.Toolkit, I then add two namespace declaration in my MainPage.xaml – here’s what the full XAML looks like now:

   1: <UserControl x:Class="SilverlightApplication105.MainPage"
   2:     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
   3:     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
   4:     xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
   5:     mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480"
   6:     xmlns:toolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit"
   7:     xmlns:mswindows="clr-namespace:Microsoft.Windows;assembly=System.Windows.Controls.Toolkit">
   8:     <Grid x:Name="LayoutRoot">
   9:         <StackPanel Orientation="Horizontal" Margin="10">
  10:             <ListBox Width="200" Height="500" x:Name="FromBox" DisplayMemberPath="FullName"/>
  11:             <ListBox Width="200" Height="500" x:Name="ToBox" DisplayMemberPath="FullName"/>
  12:         </StackPanel>
  13:     </Grid>
  14: </UserControl>

Notice the xmlns:toolkit and xmlns:mswindows in the declarations.  Now I simply wrap the ListBox controls inside a ListBoxDropTarget control:

   1: <StackPanel Orientation="Horizontal" Margin="10">
   2:     <toolkit:ListBoxDragDropTarget mswindows:DragDrop.AllowDrop="True">
   3:         <ListBox Width="200" Height="500" x:Name="FromBox" DisplayMemberPath="FullName"/>
   4:     </toolkit:ListBoxDragDropTarget>
   5:     <toolkit:ListBoxDragDropTarget mswindows:DragDrop.AllowDrop="True">
   6:         <ListBox Width="200" Height="500" x:Name="ToBox" DisplayMemberPath="FullName"/>
   7:     </toolkit:ListBoxDragDropTarget>
   8: </StackPanel>

And when I run the application I get drag-n-drop item functionality from one list to the other, complete with a semi-opaque decorator as I drag the item:

ListBoxDragDropTarget image sample

Cool.  As I drag one item, it moves to the other.  But this can do more.  What if I just wanted to re-order items within a single ListBox?  This can do it as well…after all the ListBox can be both a drag *and* drop target.  However this ListBoxDragDropTarget doesn’t work with virtualized panels (which the ListBox uses by default.  So to do this you’d have to alter your ListBox ItemsPanelTemplate to include a regular StackPanel like so:

   1: <toolkit:ListBoxDragDropTarget mswindows:DragDrop.AllowDrop="True">
   2:     <ListBox Width="200" Height="500" x:Name="FromBox" DisplayMemberPath="FullName">
   3:         <ListBox.ItemsPanel>
   4:             <ItemsPanelTemplate>
   5:                 <StackPanel/>
   6:             </ItemsPanelTemplate>
   7:         </ListBox.ItemsPanel>
   8:     </ListBox>
   9: </toolkit:ListBoxDragDropTarget>

And then you’d be able to reorder using the drag/drop behavior of your mouse:

reorder sample image

Very cool.  What’s great about this is that while I’m using simple text, you can use whatever DataTemplate you may have in your ListBox and the same functionality works…even if I added an image to my Person class and added that to the template, the functionality still works and looks great for the user:

complex template sample image

As you can see the template follows the drop.  And the drop target location doesn’t have to match the same data template!  I can have my binding in the FromBox be a complex data template, but in the ToBox only choose to bind to a single property of the class.  Nice.  Here’s an animated view of this working or click here for a live sample:

This isn’t just for ListBox elements either.  Here are the other implementations:

  • ListBoxDragDropTarget
  • TreeViewDragDropTarget
  • DataGridDragDropTarget
  • DataPointSeriesDragDropTarget

Check out Jafar’s post for some samples on the other implementations to see how helpful they can be.

So what do you think?  Good?  Hope this helps some of your scenarios with ease.  Go Toolkit!

UPDATE: Download my project I used above here.

This work is licensed under a Creative Commons Attribution By license.

| Comments

Today (19 Oct 2009) the Visual Studio team released the second beta for Visual Studio 2010 to the public.  This is a significant milestone for the team and a huge improvement over the previous beta in my opinion as a user.  As a developer, you can find out how/when you can download Visual Studio 2010 and .NET Framework 4 beta 2 from here.

After installing the tools, one thing you may notice right away is a different look of branding of Visual Studio going forward for now.  Gone is the beloved multi-colored infinity looking thing (that’s what I call it at least) and enter the updated logo.

Visual Studio 2010 brand logo

I’d encourage you to download it when you can (MSDN Subscribers can do that today, general availability on Wednesday, 21 Oct) and start playing around with it.

What’s new for Silverlight developers in VS2010?

Well, the good news is no more work around hacks to get Visual Studio 2010 working with Silverlight development!  So what happens now when you install.  Here’s my experience from a clean machine (no existing SDKs, nor any version of Visual Studio as well).

After install of Visual Studio 2010 I have this for Silverlight development:

  • Visual Web Developer
  • Silverlight 3 SDK
  • Silverlight 3 Tools (build 40818, the latest)

A few things missing here:

See below to get the October 2009 release of the Silverlight Toolkit to get all that goodness and support for VS2010.  Remember the installer for the toolkit also gives you the option to deploy the source (which you still have to unzip) which is EXTREMELY helpful in understanding how controls work in general as well as extending the controls to fit your own needs.

For .NET RIA Services, we don’t yet have a supported build for Visual Studio 2010 Beta 2.  More information on this will be coming so make sure to subscribe to my feed here for updates and watch the forums.  I’m seeing if I can work on publishing a potential work around for RIA Services users and will post an update here if I can.  UPDATE: View information about RIA Services roadmap and VS2010 from the team here.

After installing VS2010 though, you can start developing your Silverlight applications and use the editable designer surface as well.  Expression Blend will still be your friend for Visual State Manager editing and animation recording, in my opinion.

Making the designer have some better performance

For beta 2, there is a registry entry you can add (we did say it was beta right ;-)) to make the WPF/Silverlight designer perform better. 

NOTE: Editing your registry can be dangerous if you aren’t familiar with it.  It can cause wars, harm children and hurt your machine.  You’ve been warned.

To enable this, perform these steps with all instances of Visual Studio shut down:

  1. Open regedit.exe using admin permissions (on vista/win7)
  2. Navigate to HKLM\Software\Microsoft\VisualStudio\10.0 key
  3. Right-click and add a new Key named “ClrHost”
  4. In the new key, right-click and create a new DWORD32 with the name of StartupFlags
  5. Set the value of StartupFlags to 5
  6. Close regedit and use Visual Studio as you normally would

I’ve also made a reg file to make this easier.  You can download this file: Dev10DesignerFix.renametoreg and rename it to .reg and double-click it to get this entry.  I chose to force you to rename to .reg so you know what you are doing :-).  This is a step that will not be necessary in the final release version.

Silverlight Toolkit October 2009 Release

Additionally today, the Silverlight Toolkit published the October 2009 release of the bits.  Primarily this was for support of Visual Studio 2010 integration, but also includes drag-drop support for key controls as well as some charting and other API improvements/fixes.  You can read the full details of the release of the toolkit here and download the latest build.

Hopefully you all have a chance to start working with Visual Studio 2010.  I am looking forward to using the new IDE and features to help me be more productive!

| Comments

If you’re a pro Silverlight developer, this post isn’t for you.  Just a brief update that I’ve updated some of our getting started material for beginners – those who really haven’t done anything.  These will be showing up on the Silverlight Community Site soon, but I wanted to post a link to it here first.

Getting Started with Silverlight Development is a 7-part series where I aim to do my best in trying to stuff as much as possible about Silverlight development in a simple application we develop at different steps.  It uses:

  • Navigation
  • Styles/templates
  • Data Templates
  • Data binding
  • Value Converters
  • Silverlight Toolkit controls
  • Isolated Storage
  • Network connectivity
  • Web service requests to a public service
  • Out-of-browser experiences

I hope that it is simple enough for beginners to follow but also provide a broad spectrum of capabilities to the beginner.  Full code in C# and Visual Basic is provided.

Hope this helps!

| Comments

Over time a few people have contacted me about the missing WatermarkedTextbox from Scott Guthrie’s Digg sample for Silverlight he created a while back.  I had posted the updated code and binaries for WatermarkedTextbox here for you to use if you wish. 

NOTE: Incidentally this is the same code that is actually in the DateTimeTextBox that is included in the Silverlight Toolkit if you just want to use that :-).

After thinking about it though, I decided to take a stab at updating this getting started guide for new developers to Silverlight to incorporate some new features.  This isn’t for you folks that have already got your feet wet.  This is the Hello World –> have something complete in a few steps crowd.  Does it use Prism or MVVM?  No, not yet.  I think I wanted to keep simplicity to help people get started and then refactor from there.

Here’s the breakdown that I created (similar to Scott’s original flow):

I hope this helps some folks and refreshes our getting started content for the newbies!  I’m also going to try to refactor this simple application a few times to help learn the Model-View-ViewModel approach to XAML development so be sure to subscribe to my feed for updates.