I’ve decided to follow Scott Guthrie’s Silverlight example for creating a Digg Search application. It’s a nice example covering a number of topics, however…there are a few gotcha’s (problems) in it.
- The tutorial involves a number of swaping one element type for another, the compiler can get easily confused. You can get weird errors that reference the old element when it is nowhere to be found in the source code. It seems that stepping though the initialize code seems to solve this!??
- The data control in the tutorial is called Data:DataGrid, for me it’s my:DataGrid
- Part of the tutorial explains how to separate style from structure, however a number of the controls the tutorial uses don’t support styles as resources. However, if you download the sample code you’ll see that Scott has replaced those with more basic versions, for example the tutorial uses a WatermarkTextBox (doesn’t support resource styles) whereas the sample code uses a straight forward TextBox.
- The tutorial shows the application displaying images, and indeed it does show how to bind to the thumbnail image. However, neither the tutorial or the sample code actually displays images. The problem seems to be that the Linq query is trying to store an entire Xml element into a string, doesn’t work. So you need to change the Linq query from
Thumbnail = (
string)story.Element("thumbnail"), to Thumbnail = (string)story.Element("thumbnail").Attribute("src"), - Binding the Hyperlinkbutton directly to the string href of the story class doesn’t work, it needs to be a URI. So add a URI property to the story…
public Uri HrefUri{get{return new Uri(this.HrefLink);}}
Thanks for #5. I worked through the same tutorial, trying to not look at the final source to get up to speed on doing some Silverlight. I couldn\’t figure out why the href wasn\’t working so your solution was the missing link.