Silverlight 2 Beta 2 was released in June 2008; but I didn’t have time until now to catch up with the latest buzz! Switching to Beta 2 took some time; there were some installation issues, which all have been resolved with some googling.
My PicturePuzzle application needed some updates too after the switch to SL 2 Beta 2. A link to the updated application and the source codes can be found on my Silverlight Experiments page.
Here’s a list of some minor changes that I had to do to make the application function again.
When locating shuffled puzzle pieces, similar commands like this one were used:
Former Method-1:
i[nx].SetValue(Canvas.TopProperty, iy * nSliceOfCanvas * -1);
Basically the Canvas.TopProperty was assigned an int value. With Silverlight 2 Beta 2, instead of int, double has to be used. So the command is slightly changed by adding an explicit type cast to double.
Error-1: DependencyProperty of type System.Double cannot be set on an object of type System.Int32
Solution-1:
i[nx].SetValue(Canvas.TopProperty, (double)iy * nSliceOfCanvas * -1);
While retrieving the image source to form a new URI, I used the Image.getValue(Image.SourceProperty) method and converted the result to String.
Former Method-2:
Uri uri = new Uri((String)puzzleImage. GetValue(Image.SourceProperty),UriKind.Relative);
This method didn’t seem to work anymore, so I searched for a fix.
Error-2: Unable to cast object of type ‘System.Windows.Media.Imaging.BitmapImage’ to type ‘System.String’
Solution-2:
Uri uri = ((BitmapImage)(puzzleImage.Source)).UriSource;
Another error was that the radio button checked events were executed while the page was still loading. Therefore I decided to add a pageLoaded flag variable just to check out if the page load was completed or not. It seems to work pretty fine.
Enjoy the game!
[…] SL ThoughtBox. Trying to catch up, plus a new submittal from Michael Washington. CrocusGirl has updated all her work to B2. Karen Corby Reports An Early Look – VisualStateManager for WPF, so if you’re tracking WPF as […]