| Comments

Yesterday Microsoft announced that Visual Studio 2010 Release Candidate was available for MSDN subscribers and would be generally available on 10 February 2010 for the public.  This release represents a significant improvement in the overall Visual Studio product and a lot was based on beta tester feedback.

Of course, as a Silverlight developer you will be wondering: Can I still develop Silverlight 4 applications with the VS2010 RC?

Here’s the simplest form of a FAQ I could provide for you:

Q: What was released this week for Visual Studio 2010?
A: The Visual Studio team released Visual Studio 2010 and .NET Framework 4 Release Candidate builds.

Q: When can I download them?
A: If you are an MSDN subscriber, you can today (8 FEB).  Generally availability will be 10 FEB.

Q: Can I developer Silverlight applications?
A: Yes, you can develop Silverlight 3 applications with the release candidate of Visual Studio 2010.

Q: What about Silverlight 4 applications?
Q: Is there an updated Silverlight 4 Tools installer?
Q: Is there an updated
WCF RIA Services build for VS2010?
Q: Is there an updated
Silverlight Toolkit build for VS2010/Silverlight 4?
Q: Is there an updated Blend for .NET 4 Preview build?

A: At this time, VS2010 RC does not support developing Silverlight 4 applications.  This means that at this time there is no update for Silverlight 4 runtime/tools or the WCF RIA Services or other companion frameworks (toolkit controls, etc.).  This will not be enabled until the next public build of Silverlight 4 and companion frameworks.

Q: If I want to develop Silverlight 4 applications, what should I do?
A: You should stick on the public Beta 2 build of Visual Studio for now with the companion tools/framework builds.

Q: You mentioned ‘next public build’ so when will that be for Silverlight 4?
A: We haven’t released a timeframe on that availability right now. :-(

Q: Can I run Visual Studio 2010 Beta 2 and Visual Studio RC side-by-side?
A: No.

Q: Are there hacks to make Silverlight 4 tools work with the VS2010 RC? 
A: I’m sure someone might cobble something together, but frankly there are issues between the two and the combination isn’t supported.

Q: What is wrong with you people?  Why don’t you release things at the same time?!
A: If everyone could intern for a week in the developer division at Microsoft you’d see the challenges faced with various products innovating on different time schedules and resources and teams managing as best they can.  Frankly, Visual Studio is on a path.  Silverlight 4 as a not-yet-released-product has to wait for VS milestones to ensure SL tools work well with our builds.  This same holds true for the companion frameworks and Blend.  It is not a fun place to be as we are all moving targets for each other with varying dependencies.  The Silverlight and RIA Services teams are working hard to finish a product.  That is our goal.  We want to make sure not to distract resources from adding support to interim builds that we simply can’t handle right now in order to deliver a quality FINAL product for you.

Hopefully this helps, even if it isn’t what you wanted to hear for Silverlight development at this time.


| Comments

I was talking with a good friend the other day about some feedback about DataForm.  It’s great to get raw and honest feedback…that’s where you improve more than ‘it sucks’ type feedback.  One of the use cases he felt would be common with the Silverlight DataForm control (available in the Silverlight Toolkit) was the concept of confirming the delete action.  I agreed as well that confirming permanent delete actions is a common line-of-business application pattern.  It got me thinking about some things…

The Problem

DataForm is a great control.  I love it.  It will benefit many developers in the simplest applications quickly as well as some in the most complex applications with some additional configuration.  For the purposes of this demonstration, I’ll talk about the simplest scenario.  DataForm has build in controls for navigating a bound data set, as well as adding and deleting new items.  It is the deleting I’d like to concentrate on here. 

When DeleteItem is called on DataForm (via the built-in toolbar or via your own methods), it deletes the current item.  After all, that’s what you told it to do!  The problem is that the delete is fast and there is no easy “undo” method. 

The Helper

Luckily, DataForm provides a method interceptor for us: DeletingItem.  This event fires when DeleteItem is called and tells you: Hey, I’m about to delete the current item.  If you want to do anything about that, now is the time.  So there you have it…you can prevent the delete because there is a CancelEventArgs parameter passed in to cancel the remaining event.  So what would you do in DeletingItem?

Solution 1: Go modal

One thing you can do is leverage a modal dialog.  This would block the event until a modal dialog response is provided for you to investigate.  Here’s an example of what you might do in DeletingItem:

   1: private void PeopleBrowser_DeletingItem(object sender, System.ComponentModel.CancelEventArgs e)
   2: {
   3:     if (MessageBox.Show("Are you sure you want to delete this item?\nThis cannot be undone", "Delete Item", MessageBoxButton.OKCancel) == MessageBoxResult.Cancel)
   4:     {
   5:         e.Cancel = true;
   6:     }
   7: }

So what’s the problem with this one?  Nothing really.  The dialog would show, giving your user a chance to react and block the delete call until an OK is received (it cancels the event if Cancel is clicked).  But let’s look what it generates from a user experience standpoint:

confirm delete with MessageBox

Hmm, maybe there is a problem.  First, it says OK or Cancel…not really a “Yes or No” response the user is really looking for.  Second, using MessageBox will focus the dialog in the center of your window and not center of parent (or calling control).  These two things make it less ideal in my opinion.  The major positive here is twofold: it works and it’s truly modal (thus blocking the call to delete).

Solution 2: Pimp your dialog, but also your code

Silverlight is all about improving the user experience right?  Changing things around and differentiating the RIA?  So let’s use that mantra to think what we could do here.  Silverlight 3 provides a new control, ChildWindow that you could use in this instance.  It provides a modal-like experience to the end user (blocking other UI components) and gives them a focused area to provide a response.

NOTE: I’ve refactored ChildWindow into something I call “FloatableWindow” for MDI or other type interfaces.  I’ve provided my code for you to use on the .  I’ve also added a work item on the Silverlight Toolkit so if you like the idea, please vote on it!

The challenge with ChildWindow is that while it exhibits all the UI experience of a modal dialog, behind the scenes it is asynchronous.  This means that if you put a Show() call to a ChildWindow in your code, that your next line of code will run as well.

NOTE: If you think this should be changed, consider voting on the Silverlight Toolkit project for this item: ChildWindow – make it modal.

We can, however, still be creative.  Let’s explore an idea here.  We know that we have the DeletingItem event we can still tap into, so we can trigger our implemented ChildWindow like this:

   1: private void PeopleBrowser_DeletingItem(object sender, System.ComponentModel.CancelEventArgs e)
   2: {
   3:     ConfirmDialog cd = new ConfirmDialog();
   4:     cd.Show();
   5: }

The problem is that unless we cancel the event, the delete will still happen (and you can see it happen from behind the ChildWindow even…frustrating!  The ChildWindow.DialogResult is essentially worthless to us right now.  Let’s think creatively though.  What I did was create a member variable called _delete and set it to false.  This tells the DeletingItem event whether or not it really should delete.  It sounds dumb, I know, but work with me.

Now when we call DeletingItem, we check to see if we really should delete or not (really we check to see if we should cancel the event).  If we are still in “false” mode, then we shouldn’t delete but should show our confirmation window and cancel the DeletingItem event.  That’s great, but we still need to get the user response from the window!  We then need to tap into the ChildWindow.Closed event and get the DialogResult from there.  In the Closed event we can see if they confirmed the delete.  If they cancelled the delete, we do nothing further.  If they said “Yes” then we need to change our _delete variable and call DeleteItem on our DataForm again.  Now our DeletingItem handler knows we can successfully continue.

Sound fuzzy?  Sound like a hack?  Maybe so, but it works.  This gives us the opportunity to create a customized user experience for the confirmation.  Now I’m a crappy designer, but to make the point clear to differntiate from simple MessageBox, my ChildWindow has a flashing background and blurs the DataForm.  Yeah, it’s obnoxious, but that is the point for this demonstration!  Here’s the complete code for this solution:

   1: private bool _delete = false;
   2:  
   3: private void PeopleBrowser_DeletingItem(object sender, System.ComponentModel.CancelEventArgs e)
   4: {
   5:     if (!_delete)
   6:     {
   7:         Person p = PeopleBrowser.CurrentItem as Person;
   8:         ConfirmDialog cd = new ConfirmDialog();
   9:         cd.Closed += new EventHandler(cd_Closed);
  10:         cd.Title = string.Format("Delete {0} {1}?", p.FirstName, p.LastName);
  11:         BlurEffect b = new BlurEffect();
  12:         b.Radius = 10;
  13:         PeopleBrowser.Effect = b;
  14:         cd.Show();
  15:         e.Cancel = true;
  16:     }
  17:     else
  18:     {
  19:         _delete = false;
  20:     }
  21: }
  22:  
  23: void cd_Closed(object sender, EventArgs e)
  24: {
  25:     PeopleBrowser.Effect = null;
  26:     ConfirmDialog cd = sender as ConfirmDialog;
  27:     if (cd.DialogResult == true)
  28:     {
  29:         _delete = true;
  30:         PeopleBrowser.DeleteItem();
  31:     }
  32: }

You can try this out yourself here (requires Siliverlight 3): Sample confirm delete with DataForm.  Go ahead, I’ll wait. 

Obnoxious isn’t it :-).  Of course using Expression Blend to customize your own is highly recommended!

Summary

While there is no true modal dialog in Silverlight other than MessageBox (which isn’t XAML-customizable), these are two options that provide you with the opportunity to confirm your delete action within DataForm.  Hopefully these are helpful to get you to think at least and if someone has better implementations, please share them!  You can download the complete code for this sample here: ConfirmDeleteDataForm.zip

Hope this helps!

| Comments

I got enough feedback and suggestions that I figured it would be better just to put the code up on CodePlex rather than package zips on my blog :-).  Here it is: FloatableWindow project.  The latest build I have is up there which incorporates some feedback that I’ve received.

UPDATE: If you like this idea VOTE FOR IT in the Silverlight Toolkit!

Basically the ShowDialog() API operates the same way that ChildWindow.Show() does today.  No changes there, popup is used.  But when you just want some simple MDI type windows, use Show() which will not use Popup but rather add the elements as children to your root visual.  Now the key here is defining that root.  Before you show the window you’d want to do something like this:

   1: FloatableWindow fw = new FloatableWindow();
   2: fw.Width = 200;
   3: fw.Height = 200;
   4: fw.Title = "Foobar";
   5: fw.ParentLayoutRoot = this.LayoutRoot;
   6: fw.VerticalOffset = 200;
   7: fw.HorizontalOffset = 100;
   8: fw.Show();

Notice line #5 where I specify a Panel element to add it to?  That would be required.  An ArgumentNullException is thrown if it is not provided.

Thanks for the great feedback and encouragement on this refactoring.  I hope that putting it on CodePlex provides a better home for evolution and tracking issues (I know there is an animation issue now with non-modal).

| Comments

Silverlight logoAt last, Silverlight 3 is released!  It has been a long road…wait a minute, actually it’s only been 8 months since the last release!  Whoa, that’s some wicked supersonic Microsoft time there!  Anyhow, we are finally released.  A while back I wrote a post on What’s New in Silverlight 3 and it still all applies.  I’d encourage you to read that post as well.  There are, of course, some subtle changes in a few things from an implementation side of things, but those are all documented in the release.

Here’s where you go to get the exhaustive goods.  First if you don’t have Visual Studio or Silverlight yet installed and want to try it out, give the Web Platform Installer a try.  In one click we’ll install everything for you!  The image link here will install VS2008 Express (free) and the Silverlight 3 developer tools:

Here’s some links to all the other bits if you so desire:

That should give you the totality of information to get as deep as you want with all the features.

NOTE: If you are behind a firewall and get an error installing the VS tools, you may be running into a common issue with those ‘behind the walls’ with downloading the runtime.  Basically download the tools, then download the *developer* runtime (link above) and follow the offline instructions here (this was a post from earlier days but still applies).

While you are downloading the bits, take a look at some thoughts on new/changes below here.

What’s changed/new since beta?

There are a few things that are finally in the bits that we’ve talked about since beta but probably not many have seen or been able to work with.  Here’s some of my highlights:

Improved text rendering.  The team made large investments in improving the overall rendering of text in Silverlight applications.  Improved text rendering is available to all supported platforms.  Improvements for text animation have also been introduced.

Updated Out-of-browser tooling.  In the beta, the manifest had to be written by hand for taking your Silverlight application out-of-browser.  The Visual Studio tools now have a user interface for helping you do that.  When you look at the properties dialog of a Silverlight application you’ll now see the checkbox to enable these settings:

Silverlight Out of browser settings

and the resulting tooling to create the file for you:

Silverlight Out of browser settings dialog

The result is that an OutOfBrowserSettings.xml file is created and your .*proj file is decorated with some build instructions on how to compile that for the manifest.  If you have existing projects with the older settings in the manifest, it should be a quick and easy change, but I had also created a quick tool that was helping me do these in bulk.  You are welcome to use my OOBChanger ClickOnce app.  You basically point it at the folder where your Silverlight .**proj file is located and it does the work.  This is certified works on my machine utility, but I wanted to pass it along in case you had a lot to do.

NOTE: Remember to DELETE THE OLD AppManfiest settings (Deployment.Identity) or your application WILL NOT RUN.

In addition to the tooling change, almost all the Out-of-browser APIs got name changes.  For instance, instead of .Detach() it is now .Install().  Also the out-of-browser update model I’ve previously talked about has change slightly.  There is now an API called CheckAndDownloadUpdateAsync() which triggers the update check.  Once called, if an update is available, it is being downloaded asynchronously to the user.  There is an event you can subscribe to for the completion of this event to check if an update did indeed occur and alert the user.  The change here effectively is that you, the developer, now perform when you want that update check/download to occur.

Where did my design view go?!  You may notice right away that the VS tools no longer have the preview mode for your XAML in Silverlight projects.  This is by design.  We heard some pretty vocal feedback that the preview was usually turned off for most development because it was not turning out to be helpful as the applications got more complex.  The team decided put the resource investment into creating a great editable design surface in VS2010 instead and not delay the release of Silverlight 3.

ASP.NET Server Controls.  In the Silverlight 2 SDK and the Silverlight 3 beta, we had two ASP.NET server controls: asp:Silverlight and asp:Media.  These were both controls that served as wrappers to emitting the <object> tag or other JavaScript to instantiate a Silverlight object.  The <object> method is more flexible for developers on various platforms and we have decided not to include updates to these controls for Silverlight 3 SDK.  People may ask how they are going to emit params, etc. using server code, and that is still entirely possible.  We have a whitepaper talking about various methods of doing that including the simplest ones like this:

   1: <object type="application/x-silverlight-2" ...>
   2:   <param name="Source" value='<asp:Literal id="Source" runat="server"/>' />
   3: </object>

That whitepaper about the ASP.NET Server Controls can be downloaded from the Silverlight whitepapers site and includes some guidance, known issues, and things to be aware of if you are still using those controls and move to Silverlight 3.  It also includes a link to where you can get the source code for those controls if you want to extend them yourself.

Silverlight.JS updates.  Just a minor update that we compressed the bits so that if you want to use them it is a 7K library instead of a 57K library.  The “debug” (human readable) version will be available for you to download if needed at the Silverlight.js code site and is licensed under Ms-PL.

New networking stack.  What?!  That’s right a new networking stack option is being introduced for Silverlight 3 and is new since beta.  Silverlight has always leveraged the browser HTTP stack and will continue if you don’t care.  In Silverlight 3 we’ve introduced the Client HTTP stack as an option as well.  You must opt-in to use the client HTTP handling.  This gives you the ability to go more than just GET/POST (i.e., more REST-ful verbs), using response status codes/headers, etc.  You can opt-in to use the client HTTP stack on all requests, requests for a specific domain, or on a per-request basis like this:

   1: HttpWebRequest request = (HttpWebRequest)WebRequestCreator.ClientHttp.Create(new Uri(
   2:         http://api.search.live.net/qson.aspx?query=Silverlight));

Hopefully this new client stack will give you some flexibility in some situations beyond what the browser networking stack was providing.  We continue to look for feedback on improving this area.

Assembly Caching.  This feature was in the beta, but was only limited to Microsoft specific assemblies and only a few.  In the release we’re making this option available to all developers.  This gives you the ability to host your satellite assemblies and not have them packaged as a part of the initial XAP payload.  They will then be download asynchronously when needed.  This feature is great for shared assemblies in corporations as well as component vendors.

Where did DataForm go? DataForm was moved out of the SDK and moved into the Silverlight Toolkit release mechanism.  It is still available in its full awesomeness of glory, but just in a different place under System.Windows.Controls.Data.DataForm.Toolkit namespace.  Look for it (and the source!) in the Silverlight Toolkit downloads.  There were some changes here including the removal of the DataFormFields (like DataFormTextField) in favor of using the primitives more.  So instead of:

   1: <datacontrols:DataFormTextField Text="{Binding Path=FirstName}" />

you’d use

   1: <datacontrols:DataField>
   2:     <TextBox Text="{Binding Path=FirstName}" />
   3: </datacontrols:DataField>

We felt this is a more flexible model for growth in the long run for DataForm usage.

Navigation framework updates.  The navigation framework got some updates including how you use the UriMapper concepts.  In the beta you had to have it as a resource and the resource key had to be named ‘uriMapper' or it wouldn’t work.  We’ve changed that so now you can still have your mappings as a resource, and can reference them on your Frame like this:

   1: <navigation:Frame UriMapper="{StaticResource MyFooMapper}">
   2: ...
   3: </navigation:Frame>

or you can explicitly write them on the Frame itself

   1: <navigation:Frame x:Name="MyCoolFrameNav">
   2:     <navigation:Frame.UriMapper>
   3:         <nav:UriMapper>
   4:         ...
   5:         </nav:UriMapper>
   6:     </navigation:Frame.UriMapper>
   7: </navigation:Frame>

Hopefully that makes things a little more flexible for you.  Also be sure to check out the additional 7 free navigation application template themes we’re providing for you.

.NET RIA Services.  The July 2009 update for .NET RIA Services is now available for you to download as well.  We’ll be posting some deeper tutorials on how to use RIA Services with Silveright.  When you download the bits, there is a walkthrough document that helps you get a good overview of the framework.  Best of all, the July 2009 bits come with a Go-Live license!  Sweet!  Now you can get rolling on some deployment using RIA Services!  Be sure to use the .NET RIA Services forums as the team is very active there!

Browser Zoom.  Silverlight applications now respond to browser zoom requests.  So if you’re viewing an app in IE you can go down to that little right corner and change the zoom to 200% and see the wonder of the ClearType text rendering :-).

Silverlight 2 changes and quirks mode.  In my previous post where I asked you all to make sure your SL2 apps ran fine under the beta, there was a lot of questions about what this quirks mode list of changes was going to be.  At the time we hadn’t formalized the document so I couldn’t share it and I didn’t want to share something incomplete.  The changes are now outlined in the Silverlight 3 changes documentation (section 5).  There are some changes that may directly affect you (like OpenFileDialog requiring a user-initiated action) and some that you won’t care about.  The key here to remember is that even if you have this code in your SL2 application, as long as it is compiled in SL2, it will ran fine in Silverlight 3 because of our quirks mode.  If you compile in Silverlight 3, however, you will be playing by SL3 rules, so pay attention if these affect you.

What’s the deal with Blend?  Expression Blend 3 is releasing a Release Candidate (RC) build alongside the Silverlight 3 final release.  Expression Blend is a part of the overall version 3 suite for Expression which is not yet released (which includes Expression Encoder 3 as well).  The RC build was designed to ensure you can target SL3 applications.  It also includes the feature everyone is talking about: SketchFlow.  Be sure to check out the RC build and play around with it…there are some great improvements.

Encoding media for Silverlight.  IIS Smooth Streaming has already been released and you can play around with it since Silverlight 2 applications.  Expression Encoder 3 features were recently announced (including screen capture!) one of which indicated that updated media templates will be provided.  Here’s a preview of some of my favorites:

‘Expression’ theme: simple, but super elegant.  Has built-in pop-out control, cover-flow style chapter/playlist viewing and offline mode support.  Wicked.  Makes me scared about my project with Joel.

Encoder 3 Expression theme

‘Jukebox’ for audio playback

Encoder 3 Jukebox theme

The source code for these templates are provided as well so you can extend and further template to your liking.  The IIS Smooth Streaming encoding capabilities are also built into the product so you can produce your own smooth streaming bits to put on your IIS7 server.

Summary

I’m sure I’m missing some things, but there is all goodness in the Silverlight 3 release.  You just have to experience it yourself :-).  Go ahead and Get Started now!  The marketing team has also updated their site at http://www.microsoft.com/silverlight with some updated case studies and additional information for you to help learn how Silverlight can empower your developers and help you create unique experiences on the web.

Hope this helps!

| Comments

UPDATE: FloatableWindow is now on CodePlex for easier community contributions and management of latest source and builds.  FloatableWindow CodePlex Project. If you like this idea VOTE FOR IT in the Silverlight Toolkit!

A while back I wrote a post where I refactored the Silverlight ChildWindow to create a non-modal window and I called it FloatableWindow (you can see why I’m not a good marketer…hey I could have called it Microsoft Silverlight ChildWindow Refactored Edition Express).  A few folks found it useful, for which I’m appreciative of the comments.

My buddy Karl Shifflett decided to use it in Glimpse as the diagnostic window – thanks Karl!  Karl even added some code to it to basically provide a start position (HorizontalOffset and VerticalOffset).  Another request Karl had was to add resizing capabilities to the window.

I’m pleased to say that I added both of these features to the source.  I modified Karl’s offset properties a bit to not only include them in the Show() override, but also as public properties that would be used if available.  For resizing, I added a ResizeMode property which matches the System.Window.ResizeMode enumeration.  I chose to use that enumeration for some consistency with WPF APIs, but frankly it really only supports CanResize and NoResize with the default being CanResize.  You can see an example of the resizing capabilities here in this animation:

As you can see (sorry for the horrible animated image but just wanted to make it simple), the resizing handle will appear in the lower right corner of the window.

UPDATE: Based on Laurent/yaip’s feedback I reverted back to my original design, here’s the mouse out (normal) and mouse over states for the handle:

 

  I chose to make it invisible unless someone moves their mouse into that position.  Is that the wrong UX do you think?  I know it isn’t entirely consistent with something like WinForms, but I wanted to be a little different. 

Additionally I wanted to use the SizeNWSE Cursor as a normal WPF/WinForm window would use, but unfortunately that’s not a valid Cursor for Silverlight right now.

I did try to make the resizing adorner a template part so you could make it something else (right now it is just a path).  I haven’t really tried messing with it that much though.

I think my math might be a bit off in some scenarios and I’m still frustrated with the Popup and ZIndex issue in Silverlight, but I know there is an open issue for Silverlight to look at this so I’m trying to stay calm about it.  Anyhow, some subtle adds to make it hopefully just a bit more useful for anyone who cares (or cares to learn from it).

You can download the source code here: FloatableWindow_1.3.zip

Hope this helps and I appreciate any comments regarding the update or if you see issues in your scenarios.