Adding shapes to your Windows Phone using some simple XAML and C# code

If you are starting out building games, and want to check out XNA development, you might want to take a look at my blog at http://blogs.msdn.com/devschool. It discusses lot’s of things, randomly.

How do you add shapes to a silverlight based project in Windows Phone. First you have to have a root for your game. So open Visual Studio Windows Phone Express and on the MainPage.XAML (this is for version 4.0 if you are looking at this in the year 2015).

First off, when we get to the code piece, you will see that I use one of the Security components: RNGCryptoServiceProvider, this allows me to use a random number generator that creates a more random number, or in my way of thinking a random number that has less “color”. The random number class that is generally included in the .NET Framework is random, but the number generated isn’t colorless, if you looked at it through a spectrum analyzer, you would see that there is a number of numbers it is usually generating. For some games, that isn’t good enough. In this case, if you try to use the random number generator included in the .NET Framework you would see that the circles and squares have a pattern. If you use the RNGCryptoServiceProvider, the circles and squares are shown more randomly, feel free to experiment. And students in my class at CSUDH are expected to demonstrate the difference in their homework (so I won’t show the solution here, yet). URLs are provided with the code, in comments that show you where to go to get more information about the RNGCryptoServiceProvider.

Now get started building code:

Change the default code, which in the Visual Studio WIndows Phone Express 4.0 looks like the following: