Use the Code: WRAC11
Moving images in Silverlight is pretty simple, the code works on the phone as well as on the web. Here is the simplest code I could come up with:
For phone Silverlight, copy and paste the code below into the initial XAML Page, this assumes a single page of XAML which is default named MainPage.XAML, this creates a canvas and three images, but you haven’t added the Images yet. This effort completes steps 1 and 2, make sure that the line (2)
x:Class=”PaddleMove.MainPage” stays the same as the namespace in your project or it will throw an error:
For Web Based Silverlight, copy and paste all of the code below into the initial XAML Page, replacing all of the code, except for the first line, if you change the name of the class then the namespace has to be changed as well.
To add the images do the following, select “Existing Item…” and go to the location where your images are located, this completes step 3:
Cut and paste the code below, in the Web Silverlight you will need to change the “PhoneApplicationPage” to “UserControl”. Make sure that the namespace matches.
Bear in mind that the Phone App won’t be able to use the mouse on the real application, but for now, the mouse gives you feedback that you have operational code.
That’s it, if you run the Windows Phone 7 App in the emulator, it should work. The same for the Web Silverlight.
If it doesn’t let me know. Leave a comment.