In the tutorial titled “Introduction to Silverlight 4 and WCF RIA Services’”, I created an application that keeps track of golf course information and scores and also computes a golfer’s handicap. This application used Silverlight 4 and WCF RIA Services with the application logic located in the Silverlight code-behind. In the tutorial titled “Silverlight 4 and the Model-View-ViewModel (MVVM) Pattern’”, I introduced MVVM concepts with a very simple example. In this tutorial, I revisit the golf application by refactoring the code-behind into two view models.
I must admit that I have struggled for some time really understanding the MVVM pattern. I read a lot of articles and blogs, and I learned a lot, but I never really “groked” the concept to my satisfaction. I read John Papa’s blog on Silverlight 4 Commanding. I worked with his code, converting it to VB, and then started to experiment. The result of the experiment was the Silverlight 4 and the Model-View-ViewModel (MVVM) Pattern tutorial. Then I started working with the Golf Handicap Application, this time building a view model for the Course management child window, and another view model for the score management child window.
Well … GROK! I got it it. It was one of those nice experiences when a small intellectual step brings great satisfaction.
I hope that this new tutorial might help you “see the light” in the MVVM and Silverlight world. I should point out that there is no single approach to implementing the MVVM pattern so you may find other approaches better for your needs.
bill
I have replaced my prior video on Silverlight and MVVM with a new and improved one. This new video takes advantage of the new features in Silverlight 4 that makes binding between the view and the view model much more straightforward. Silverlight 4 now includes commands that allow behavior on the user interface, such as mouse clicks, to be detected and communicated to the view model via binding.
In this tutorial, we look at a learning example that covers binding the view to view model via parameters, using commands, and including parameters with commands. It also uses RIA Web Services to hook up to a copy of the NorthWind database.
I just posted a new tutorial that uses Visual Studio 2010, the Silverlight 4 RC, and WCF RIA Services RC. This tutorial walks through the creation of a Silverlight Client (a golf handicap application) that uses WCF RIA Services to maintain and update data stored on a server.
The application is sufficiently complex to show some real-life requirements while not being too complex to make it hard to comprehend.
This tutorial uses a traditional event-driven paradigm with code-behind to interact with the UI and the RIA services. I plan to refactor the code and create a second version of the application using the MVVM pattern and publish that tutorial in April.
bill
I have just published a new video tutorial showing how one can create a useful Windows WPF Application using Visual Studio 2010 using the new, significantly improved Cider graphical editor.
In Visual Studio 2008, the graphical editor for creating Xaml-based user interfaces was really sad. I know I just gave up on it and quickly became a Xaml coder. Given that experience, I was extremely pleased with the progress the VS team did in improving the “drag ‘n drop” experience in Visual Studio 2010.
Using the Toolbar, the Data Sources window, and the Properties window, one can create a useful application without writing any Xaml or VB code. The application, shown below, displays Orders and Order Details for a selected Customer.
Microsoft’s second generation graphical design experience with WPF Applications is a great improvement over it’s initial release in VS 2008.
RAD development is appropriate for all applications, but it is really nice to be able to create a prototype quickly and in the “spirit” of Visual Basic.
bill
Microsoft has released the release candidate for Visual Studio 2010. I have been working on a number of new tutorials and with the release of the release candidate, I’ll start publishing new videos.
With the release of VS 2010 (RC), Microsoft has also released an extensive Training Kit that includes Visual Basic material. You may find the information in this Training Kit helpful as you try to understand the new and enhanced features of the Visual Basic, Visual Studio, and a number of new .NET Framework 4 features.
bill
I thought it might be interesting to show you the page view statistics on the tutorials on my site, myVBProf.com. The table below summarizes the year 2009. I hope you;ll find the offering for 2010 helpful.
bill

As we enter the year 2010, the status of developer tools from Microsoft is a bit confusing. Visual Studio 2008 is released while Visual Studio 2010 is at beta 2. Silverlight 3 is the released version while Silverlight 4 is at the beta stage (but only for VS 2010). MVC version 1 is released while MVC 2 is at RC the stage (but only on VS 2008). WCF RIA Services is in beta on VS 2008 but is still a preview for VS2010 (part of the Silverlight 4 package). [Note: I think I have that all correct.]
Since I like to provide videos on the latest and (hopefully) greatest stuff, I am kind of stymied by the different bits that vary across VS 2008 and VS 2010. This will all likely synch up come around April or May of this year, but until then, things are tough.
What I plan to do in the meantime is try to figure out all the new stuff and write a couple of tutorials using what bits I can make work. Right now I am working on a VS 2010-based Silverlight 3 project that uses ADO.NET Data Services. Most of what I will include will work with VS 2008 and will likely work without any changes when VS 2010 is released.
Having "off-cycle" products is nice, but at times like these, it makes for whole lot of confusion.
bill
The WCF RIA Services team released preview bits for VS 2010 (beta 2) and Silverlight 4 beta. I have put together a simple tutorial that shows how one can use drag ‘n drop to bring data to the user interface.
I use the AdventureWorksLT2008 database to display customers, their associated order headers, and the line items associated with an order.
This application was created by writing a single query in the RIA Services class:
There were no lines of XAML written by me (there was a lot auto-generated by the designer).
The fact that a drag ‘n drop experience was demonstrated at PDC ‘09 by Brad Abrams, a Product Unit Manager at Microsoft, has produced some comments on the merits of drag ‘n drop. An interesting post on Shawn Widermuth’s blog is typical of the issues being raised.
Enjoy … bill
When you deploy a Silverlight application that uses an ADO.NET data service to a hosted service provider, you need to make some changes in order for the service to work properly. The following describes the steps I took to overcome the problems. Thanks to Phani Raj Yayavaram Narasimha, Mike Flasko, and Elisa Flasko at Microsoft for their help resolving these issues.
Modify Web.config in the Silverlight web application
Since the hosted server supports many different sites, it is necessary to tell your application which site is hosting your application. If you fail to do this, you will get an error similar to the following:
This collection already contains an address with scheme http. There can be at most one address per scheme in this collection.
To do this, you need to add a “<baseAddressPrefixFilters>” element to the “<serviceHostingEnvironment>”. The highlighted text shows an example.

Modify the Service Reference in the Silverlight Code
You also need to change the service reference inside your Silverlight code to point to the service with an absolute address. Following is a sample that I used in my application:
Defining a Single Authentication Scheme
Your site must have one and only one authentication scheme. If you have more than one authentication scheme defined, you will get an error similar to the following:
IIS specified authentication schemes 'Basic, Anonymous', but the binding only supports specification of exactly one authentication scheme. Valid authentication schemes are Digest, Negotiate, NTLM, Basic, or Anonymous. Change the IIS settings so that only a single authentication scheme is used.
I reduced my site’s authentication to “Anonymous” and everything worked great. The exact details on how you do this vary from ISP to ISP. I use DiscountASP.NET and I used the IIS MMC on the IIS 7 server hosting my site. You need to check with your ISP to determine how to do this on their hosting site.
Microsoft is at it again releasing a number of upgraded technologies in a very short period of time. At PDC 09 I am seeing a new release of MVC (MVC 2 beta), Silverlight 4 (developer preview), and two versions of RIA Services (WCF RIA Beta for VS 2008 and WCF RIA Preview for VS 2010 beta). This is on top of the recent release of beta 2 of VS 2010. I have spent most of today trying to understand the new releases and trying to decide which one I’d start to play with.
I have decided that my first area of study will be WCF RIA Services Preview for VS 2010. After talking with some of the RIA team, I decided that although the “preview” is less stable than the “beta”, the functionality that it has is more interesting. Be aware that the two releases (the beta for VS 2008 and the preview for VS 2010) do not share identical sets of functionality.
I have had a chance (under NDA) to already take a look at some of the really neat new stuff like Inheritance, Compositional Hierarchy, the Presentation Model, Drag and Drop support, and improved live Intellisense. All these new features are available in the preview available for VS 2010 so that’s where I am going to focus.
I am retired and can do anything I want with my time
I cannot imagine how someone with a full-time job has time to keep up with all the new stuff. Hopefully you’ll find the videos I create that share what I learn an effective way to at least get a sense for what’s happening.
bill
Microsoft just announced a new release of RIA (Data) Services. As the name implies, the new release (the first beta) now uses WCF as its underlying data transport protocol.
I posted a tutorial, Silverlight LOB Data Strategies, that compared RIA Services with IdeaBlade’s DevForce Silverlight and ADO.NET Data Services from Microsoft. In that tutorial, I compared the “size” of the data package downloaded to the client using each technology. RIA Services did not do well on this metric.
Shortly after posting the results, I heard from Deepesh Mohnani, a Product Manager on the RIA team, who let me know that his team was doing work to improve the download package size. It turns out that the incorporation of WCF was the basis of the improvement.
About a month ago I was given a preview of the new bits and ran my test again using the WCF technology. The size of the download package went from 2.2 MB with the July Preview down to 0.72 MB with the WCF technology. My download package included some binary images and WCF handles this type of data much better.
With the incorporation of WCF as the data transport technology, RIA Services moved from producing the largest package size to producing the smallest package size (0.72 MB versus 1.01 MB for DevForce Silverlight and 1.2 MB for ADO.NET Data Services).
I’ll be experimenting with the new beta release and likely post a video or two talking about the improvements.
bill
I have published a new video that covers Silverlight 3 and Visual Studio/Visual Basic 10. The tutorial shows you how to build an application using the "digg.com" API and web service. It is an updated version of an application Scott Guthrie published when Silverlight 2 was introduced but has been updated to take advantage of Silverlight 3 features such as Child Windows. It also demonstrates use of the new Cider visual Xaml editor available in VS 2010. This is a much-improved editor (compared to the almost useless version in VS 2008) although I still prefer working with the Xaml directly.
In addition, I show some of the new features available with VB 2010 including implicit line continuation and auto-generated properties. I also show one of my favorite tricks using XML schemas to enhance Intellisense when writing LINQ queries over XML.
Visual Studio and .NET Framework 4.0 Beta 2 are now available for downloading. This is still a “Beta” product so there are issues outstanding that need to be resolved. However, there are a number of technologies “built in” to the product, e.g., Dynamic Data 2.0, MVC 2.0, and Silverlight 3. There are some technologies that are not yet there but they should be coming soon.
Scott Guthrie states that:
VS 2010 and .NET 4 bring a huge number of improvements and additions. They include big advances for ASP.NET web development, WPF and WinForms client development, SharePoint development, Silverlight development, data development, parallel computing development, and cloud computing development. VS 2010 also delivers a ton of improvements in the core IDE, code editors, programming languages, and enterprise design, architect, and testing tools.
I will be using VS 2010 in a new set of videos and I encourage you to download a copy of the Beta and try out some of the new stuff. I ALWAYS install beta products using a virtual PC image and NOT on my production operating system. I have done so with VS 2010 using Windows 7 as the host system (it’s my production OS) and Virtual PC for Windows 7. You can also use Vista or XP as the host and Microsoft Virtual PC 2007 SP1.
VS 2010 is a totally rewritten using managed code. It also uses WPF (xaml) for its visual interface.
Enjoy … bill
I was wandering through the UW Bookstore the other day and took a look at some prices for textbooks. WOW - they are really expensive. One new textbook for an Introduction to Information Systems course was priced at $175. I have a couple of textbooks from when I was an undergraduate on my bookshelf. A book titled "A Guide to FORTRAN IV Programming" by Daniel McCracken cost $3.95. Another, "BASIC, An Introduction to Computer Programming Using the BASIC Language" by William F. Sharpe also cost $3.95.
Ok, so my texts were purchased a long time ago when the price of gasoline was $.35/gallon. But if gas prices had risen like textbook prices, we would be paying over $15/gallon. Why are the prices so high?
Having written a few textbooks, I am familiar with the economics of college textbook sales. The price of the book is set by the publisher, let's say $100. The author gets about 15% in royalties so the author gets $15. The remainder, $85, goes to the publisher to cover development costs (editing, proofing, design layout, etc.), printing costs, advertising/sales, and finally profit. The publisher also assumes the risks associated with sales not meeting projections meaning that they may not recover all their fixed costs.
The bookstore sells the book with a 25% markup ($25 in this case) so the student pays $125 for the book. Note that the bookstore makes more per book than the author.
A typical bookstore will buy the book back from the student at the end of the quarter/semester generally paying the student 50% of the original price. In this case, the student gets back $67.50. The bookstore then marks up the price by 25% ($84.37) and sells the book again (making an additional $16.87). The publisher and the author make NO money on this resale and herein lies the problem.
In the "old days", there was not a very viable used book market. This meant that many more new texts were purchased each quarter which contributed to the publisher's income. Back in the old days, this additional income coming from higher new book sales meant that the original price of the book could be lower and still make a reasonable return on the book.
With the advent of better information systems that made it possible for bookstores to have better information on where the used books could be found, and the advent of fast, lower-cost shipping, the used book market started to thrive. Publishes responded by raising the initial price per book and new sales fell. Students, who were the ones paying the higher prices, starting selling back more of their textbooks to reduce the overall cost to them. Students selling back more books enhanced the used book inventory and new book prices went up even more.
We are now at a stage where the price of a new book is really unreasonable. This opens up alternatives such as self-publishing by authors as well as new media (electronic books). Of course, electronic textbooks still require an author and the price of original material will only go down when the traditional publishers step out of the loop. Watch for companies like Amazon making direct contracts with authors to make material available for Amazon's electronic distribution.
What about the "traditional publishers"? They will likely follow the path of the dinosaurs. They failed to foresee the used book market, failed to lobby lawmakers for "perpetual rights" like the music and film industry enjoys, and because of this lack of foresight, they are likely going to price themselves out of business.
bill
I recently converted the “myVBProf.com” site from an “aspx” design to a Silverlight application. The original site used Google Analytics to collect and analyze usage and I needed to do something similar with the Silverlight site. This new tutorial explains the options I finally settled on to collect data on usage. I use both a “custom” approach where I create an ADO.NET Data Service to add “time stamp” data to an SQL database. I also use the Silverlight HTML Bridge to make use Google Analytics.
I also wanted to be sure that search engine spiders could find and index my new site. Since most of the key words used by the search engines were embedded within the Silverlight application, and not available to the spiders, I consulted a number of sources to see what strategies made the most sense. I finally settled on the advice of Tim Heuer who suggested that I “create alternate content for those pages and put it in the object tag area so that non SL readers (like search spiders) will see that instead of your app.” I show how I did this in the tutorial.
bill
When we build a curriculum, we have to carefully evaluate course objectives. In considering a specific course, we need also consider what I call the "appropriate level of understanding" we expect students to achieve within the course.
For example, I am currently working on an on-line course with its major objectives of introducing Visual Studio and understanding some fundamental programming concepts using Visual Basic. There are always more things that we want to cover but cannot because there is simply not enough time (this is where the intermediate and advanced courses take over). I like to use the terms concept understanding, working understanding, and expert understanding. Concept understanding means that someone understands a concept and sees it value. One might be able to create an example or two of the concept but probably not much more. Working understanding means that a person can use the technology and make productive use of it. Expert understanding means that a person "really" understands the concept to the point where they might want to extend it or might be able to apply it outside the context where it is typically used. For an introductory course, we need to focus on "concept understanding". For example, consider regular expressions; they are really rather tough to understand at a "working level" but their value can certainly be perceived "conceptually". In an introductory level course, I see my job as making the student aware of regular expressions and what they are used for; give them a chance to try them out (perhaps by using the Web Validation controls). An intermediate course would pick up on the value of the concept and provide more "working" understanding.
Often a course design does not appear to have considered these levels of understanding and thus, ends up going too deep or two shallow. Of course, a course does not live in a curriculum in isolation - it must be designed so that by the time the student has finished a course sequence, the appropriate level of understanding has been achieved. It is also important to define a curriculum's overall level of understanding. My personal opinion is that achieving a concept and working understanding is possible in a formal educational setting. On the other hand, expert understanding really requires "on-the-job training" and a lot of experience. This can be obtained within a university environment but not without the active participation of business community giving students access to "real" problems using intern opportunities or other similar programs.
bill
In my entry titled .NET RIA Data Services & Images, it was pointed out that the July Preview of .NET RIA Data Services did not handle database images stored in the database very well (it produced large files returned to the client). It was also pointed out that this situation was being addressed and would be resolved.
Placing actual images into the database is generally not a good idea. Instead, storing URI’s to the actual file in the database is generally a better idea. Using this approach, the images can be easily changed without impacting the actual database. In addition, one can avoid downloading the larger image bits if the image is not used by the application. [Note that Silverlight components, like the DataGrid, do not work with public anonymous types, so generally the entire entity, including any images, are downloaded to the client.]
So you might ask “Why did I include the thumbnail images in the database?” The answer is simple; I didn’t. I was using the AdventureWorks Lite database provided by Microsoft. In the Product table, there are two fields defined that deal with the product images:
While this design may have been OK for relational database queries, where a subset of fields could be retrieved, but it presents a problem for other technologies where the only practical choice is to retrieve all the fields.
Perhaps the best solution would be to work within Silverlight to make it possible to bind a DataGrid (or other components) to a public anonymous type (such as a subset of the properties of the Product entity).
bill
In my tutorial Silverlight LOB Data Strategies, I provided a comparison of the three different data strategies I compared:
I recently heard from Deepesh Mohnani who is part of the Microsoft RIA team. His concern was the large “Download Package Size” of .NET RIA Data Services compared to the other two options. Deepesh stated that
“I noticed you are returning thumb nails with every product and with the bits you have we were very inefficient. We have made significant changes from our last public release and are now handling thumbnails more efficiently.”
Deepesh has offered to make the newer “bits” available for my testing and when I get them, I’ll run the application again to see what the new package size turns out to be. Regarding the fact that the application is downloading thumbnails, I’ll address that in another blog entry.
You should remember that the RIA product is still at the CTP stage and that a lot of changes should be expected before the product is released; please keep this in mind before drawing any conclusions.
bill
I have been trying to understand the Model-View-ViewModel pattern for a while and to be honest, getting a good grip on the idea was eluding me. I read many articles; some were too general to be helpful, some were written specifically for WPF (which does not map well to Silverlight because of Silverlight’s lack of commands and triggers), or were shown in applications that were just too complex to really see what was happening.
Then I read Shawn Wildermuth’s article in MSDN Magazine. Shawn showed a fairly simple MVVM example using Silverlight and C#. Thanks to the efforts of Lisa Feigenbaum, Shawn’s code was provided not only in C#, but also in VB.NET in the MSDN Code Gallery.
I decided that I would create my own simple Silverlight client using the MVVM ideas presented by Shawn. I just posted a new tutorial that shows how this application is designed. In this tutorial, I look at a very simple ViewModel that deals with displaying all products from the AdventureWorks database. It shows two versions of the data contract, one using .NET RIA Services and a second using ADO.NET Data Services. In this example, the view is defined as a Silverlight client.
I have not been blogging for a number of years because frankly, I didn’t have anything to say. However, now that my tutorial site, myVBprof.com is getting more action, I have decided to start with some limited blogs.
Most of my blogs will deal with the tutorials I post so if you want to keep updated on new videos, you might want to subscribe to the blog. I will also “spout” off on other topics if I think I have something to say.
bill