London Azure Camp slides and demos

London .NET Developers group logo

On Saturday November 15, 2014 I was invited to speak at the London Azure Camp hosted by the London .NET Developers group in London, Ontario, Canada.

The group is led by Tom Walker (@Tinytoot) and his team of volunteers as they try to spread the word about everything .NET in the City of London.

Alongside Tom and myself, there were presentations by a trio of Microsoft MVPs: Lori Lalonde (@loriblalonde), Andrei Marukovich (@amarukovich) and Julien Stroheker (@Ju_Stroh).

Tom invited me to speak on both Microsoft Azure Mobile Services and Microsoft Azure Media Services.

My slides are based on the Azure Readiness Content provided my Microsoft. However, these slides have been scoped down to my session and the notes field of each slide has been expanded with additional content.

I have published my PowerPoint slides as downloadable files through Dropbox: Cloud Powered Mobile Apps with Azure | Build end-to-end video experiences with Azure Media Services.

They are also available for viewing and download through SlideShare: Cloud Powered Mobile Apps with Azure | Build end-to-end video experiences with Azure Media Services.

As well, I have zipped up my demonstrations and added them to Dropbox. In this file you will find the step-by-step notes to re-create the demos plus all of the code snippets. The zip file also contains the PowerPoint files listed above.

You can also find these links as well as more information about my previous public speaking engagements under my Speaking page.

Please contact me if you have any follow up questions from the event. My contact information is also available within the slides.

London .NET Developers Windows Azure Cloud Camp presentation slides and source code

LondonDOTNETDevelopersLogoOn Sunday March 16, 2014 I was invited to speak at the Windows Azure Cloud Camp hosted by the London .NET Developers group in London, Ontario, Canada.

This group is led by Tom Walker (@Tinytoot) and his volunteers as they try to spread the word about everything .NET in the City of London.

Tom invited me to speak on Windows Azure Mobile Services (WAMS) and how it could be used in conjunction with Windows Store apps. In my presentation I showed how to use WAMS to add storage, integrated authentication and even Push Notifications to Windows 8 Store apps in literally minutes. I also did some server side scripting and talked about the API calls you can use to populate Live Tiles for your apps.

I have published my slides as a PowerPoint file through Dropbox. They are also available for viewing and download through SlideShare.

As well, I have zipped up my Visual Studio demonstrations and added them to Dropbox. In this file you will find the step-by-step notes to re-create the demos plus all of the code to paste in.

Please contact me if you have any follow up questions from the presentation. My contact information is also available within the slides.

Using Notepad++ to write C# code

Notepad++ is a free source code editor that runs on the Windows operating system. It has become the standard text editor on most developer’s machines and it has replaced the lowly Notepad tool that comes with any Windows OS.

Notepad++ is not only my favourite text editor but it is my favourite tool for development after the Visual Studio IDE.

Features

It is very versatile in looking at all types of files and it has many programming language syntax highlighters built in. It also supports many plugins that can make tedious tasks very simple. Some of my favourites are Compare (for file comparisons), NppFTP (for moving and editing files on different systems) and JSON Viewer (for formatting JSON).

Although I have explored many files with the program I have never tried to write a complete Hello World in C# with it before. This article will explore some of the neat things that you can do with Notepad++ and how we can leverage the tool to write a simple program. We will then compile it using the C# compiler that is available on the Visual Studio Developer Command Prompt.

With Notepad++ you get some of the same features you would with the Visual Studio IDE including:

  • Support for C# keywords including color coding
  • Collapsing of methods and regions to make examining code much easier
  • Auto completion (similar to IntelliSense) for C# keywords and .NET namespaces

To enable syntax highlighting for your Hello World project make sure you set the language to C#.

C# Language

Auto Completion

To enable auto complete while coding in any language within Notepad++ press the CTRL + Space bar keys to see the list. You can then arrow up and down within the list to see your options. From there you can hit Enter to insert your selection into the document.

Notepad++ auto completion

Developers can also modify and extend the auto completion options available to them by editing the XML file associated with the language they are working in. You can find this file in the Notepad++ install directory on your computer. Normally this would be the default location of C:\Program Files (x86)\Notepad++\plugins\APIs\

Below you can see what the C# file (cs.xml) looks like when it is opened.

C# Auto Complete XML

As you can see from the list both of the new .NET 4.5 keywords for Async and Await are not available to the user. You could simply add them here to start working with the newest functionality of .NET within Notepad++.

Compilation

Let’s now return to our Hello World program that we are writing. Notice I have added a second Using statement to the class file below to allow me to raise a message box as well as print the results out to the console. To compile this file you must save it as a *.cs file. You will see I named mine HelloWorld.cs.

Hello World Completed Code

Now open up the Visual Studio Developer Command Prompt and cd into the directory where your saved file is located.

For this next part we will use the command line C# Compiler to make our code executable. The C# Compiler allows us to understand how C# compiles our code and it gives us a deeper understanding of the .NET Framework. While I would not use it for huge projects it is nice to know I can create a C# project without the Visual Studio IDE.

From the command prompt you can run the csc –help command to see the full list of options available to the developer. For general purposes though you will only need a few items:

  • /out allows you to set the file name of the assembly to be created. If not specified then the output is the same as the initial *.cs file name
  • /target:exe allows you to set the default assembly output to an executable. This is the default and it can be removed for this type of application
  • /target:library allows you to set the assembly output to a *.dll
  • /target:winexe prevents the console application from appearing in the background

We can now compile our HelloWorld.cs file into an executable. To do this we can simply enter the following into the command prompt:

csc HelloWorld.cs

Visual Studio Developer Command Prompt CSC Command

We will produce a file in the same locale named HelloWorld.exe.

If we want to be more verbose or if we want to change output names then we can do the following:

csc /target:exe /out:HelloWorld_New.exe HelloWorld.cs

Visual Studio Developer Command Prompt CSC Command With Outputs

This will produce a file in the same locale named HelloWorld_New.exe.

If we run either of these Hello World executable files we will get “Hello” written to the console and “World” written to a message box.

Hello World

In this article I have showed you how to create a C# class file and how to compile it into a Hello World application. Hopefully you have found this blog post useful. If you have other Notepad++ tips please leave a comment below as I would love to read them.

Formatting code on a WordPress.com site

I was recently reading an article by Scott Hanselman entitled How to Post Code To Your Blog and other Religious Arguments. In this post he describes the best way to show your source code on your developer’s blog. Many of the examples relate to using the excellent tool Windows Live Writer (WLW). This application allows you to compose and manage your blog posts. You can import your WordPress theme, write your story, add images and preview how it will look all while you are offline. You can then choose to post a draft to WordPress for final tweaking (something I highly suggest) or you can Publish directly to your blog.

In the article Hanselman talks about the fact that you will probably want to add some code to your blog post to illustrate your article and mentions you could just copy your code right into your HTML. However, it will not have any of the color theming most IDEs incorporate. This will make the code harder to read. He then talks about using some of the syntax highlighters that are available. You can import the highlighters into WLW and the code will appear much like it does on your IDE. However you will need to also use a JavaScript file on your website so that the code can be rendered correctly there as well.

This process will work for any WordPress.org site since you have full control over the code and where it is hosted. With a WordPress.com site though you are limited in how much you can manipulate your blog theme and the posts within it. This includes the fact that you cannot append any sort of scripting file to your site. You can read more about what types of code WordPress.com allows on this support page.

You might be thinking about just inserting images of your code instead of playing around with formatters. This is something I used to do and I found it a much easier process. However I also find it very frustrating when I visit other blogs and I find a code snippet I need that turns out to be an image and not text. Typing this out just adds to my frustration. As Hanselman states in his article placing code as images “…is rude to blind folks, and not useful as GoogleBing can’t see it. Don’t do this. You’re a bad person.” The point about having your code indexed on Google and Bing is especially poignant as you want people to be able to find and use the examples you constructed to illustrate your blog post.

So are we stuck with having unformatted code in our WordPress.com blogs then? No – there is a solution. As part of Alex Gorbatchev’s SyntaxHighlighter project much of the source code formatting used in the WLW plugin and accompanying JavaScript file has found its way into WordPress.com. The sourcecode formatting shortcode can be wrapped around sample code to preserve its formatting and provide syntax highlighting for certain languages. By wrapping your code like this:

[sourcecode language=”csharp”]
RadioButton GetCheckedRadio(Control container)
{
foreach (var control in container.Controls)
{
RadioButton radio = control as RadioButton;

if (radio != null && radio.Checked)
{
return radio;
}
}

return null;
}
[/sourcecode]

you will see output like this when you post your article:

 RadioButton GetCheckedRadio(Control container)
 {
 foreach (var control in container.Controls)
 {
 RadioButton radio = control as RadioButton;

 if (radio != null && radio.Checked)
 {
 return radio;
 }
 }

 return null;
 }

The [soucecode] language attribute can be used with multiple programming and scripting languages including C#, CSS, Erlang, HTML, JavaScript, Java, Perl, PHP, Python, Ruby, SQL, VB, XML and many others. If you leave the language blank then the code will default to plain text with no highlighting.

There are also some configuration parameters you can use to display your formatted code including changing the line numbers, collapsing the code window upon form load and disabling line wrapping. You can also choose to hide the toolbar that displays on mouseover. This toolbar allows your users to copy and print your formatted code.

Note: Placing the sourcecode shortcode tag in your WLW post for publication may cause display issues with your code once posted. Do not trust the Preview tab in WLW since it might not be reflective of your published article. Instead click the Post draft to blog button and perform a final clean up within the WordPress editor.

Finally, the [soucecode] tags will format and display your code exactly how you post it on your blog. So make sure your line spacing and indents are how you like them before you publish.

If you are a WordPress.com user and regularly post code to your blog I suggest you check out the [soucecode]shortcode. As you can see it is not a lot of work to make your code snippets accessible to all users. I and other developers will thank you when we visit your site.

Using Dropbox, Site44 and Google Drive to create a quick registration site

I recently came across a new company called Site44 and they have come up with a very neat product. By connecting your existing Dropbox account their site acts as a website hosting service for your HTML pages. This means that in mere seconds you could have a functioning website up and running that you can modify by simply overwriting your existing HTML file with a modified one that incorporates your new changes.

In this blog post I will delve into all three technologies and show how we can link them easily to create a quick user registration site for any community event or contest you might be running. By harnessing the power of Google and Site44 you can give your organization a free online website simply and easily. For less technical people you could even choose to create your webpage with Microsoft Word and save it as an .htm file. For this demonstration though I will code a simple site using Notepad++ and I will also include some CSS, JavaScript and jQuery elements to show you the power of Site44.

Dropbox

Dropbox was founded in 2007 and it is a free cloud storage file system. Much like Microsoft’s SkyDrive or Google Drive you can upload numerous types of files to the Dropbox server so that they are accessible to your account anywhere is the world. It comes with 2GB of space initially. You can synchronize your files by using their web interface to upload and download items or you can install their program onto your machine which will create a Dropbox folder structure for you. You can then drag files into this folder and Dropbox will sync your items for you.

Dropbox allows both folder and file sharing with anyone, even if they are not Dropbox users. You can choose to make folders public or private and then you can share links to these items. For the purposes of this demonstration you will need a Dropbox account. You can create a Dropbox account here. (Full disclosure: this is my referral link).

Site44

The tag line for Site44 is “absurdly simple web hosting.” In essence the company’s service turns Dropbox folders into websites. Having played with the site for a little bit I can honestly say that their tag line lives up to its name. It was easy to get started and I had my test site loaded within minutes. In fact it took me longer to code the HTML page than it did to prep the site. As you will see in the demo below the process could not simpler!

It is free to use Site44 and with the unpaid account you get five websites and a data transfer limit for all sites of 100MB/month. A word of warning from the Site44 team though. The service is still in beta and so they have posted this disclaimer: “Although it has undergone significant testing and is not expected to change significantly prior to general release, the use of Site44 is not recommend for production environments. You are encouraged to use Site44 for testing and non-critical purposes only.”

Due to the bandwidth restrictions on the free Site44 account you will not want to stress the system out by placing large files or pages with heavy content on your site as you might run the risk of maxing out your limit. As Site44 says their service is for lighter loads and is an excellent way to debug some of your code. You could also use the service to house any non-sensitive project proposals or mock-ups that you might want to demonstrate to clients.

Finally, Site44 only supports client-side scripting which includes JavaScript. Any server-side scripting of PHP or ASP.NET pages is not allowed. Placing such pages on your site will not fail but will simply show the page code to the viewer.

Google Drive

Google Drive was released in April 2012 and it is similar to Dropbox in that it is a free cloud-based file storage system. Like SkyDrive and Dropbox it also provides a synchronization service from your computer to their servers. They offer an initial 5GB of space. Google Drive is an extension of Google Docs which is a set of tools that allow you to create and collaborate online to generate documents, spreadsheets, presentations, etc.. Files created in Google Docs get housed in Google Drive automatically. They can then be downloaded to your personal computer for editing. Both of these features are accessible to anyone with a Google or Gmail account.

Tutorial

Let’s first create the HTML page that will house an introduction, some instructions and the link to our Google Docs file. When it is rendered it will appear as a form on the page so people can enter their information. I will also include on this page some calls to CSS, JavaScript and jQuery to demonstrate that all three are supported on Site44. (Note: all of the example code used in this demonstration will be available for download at the end of this post.)

Listed below is the HTML for my site. As you can see it is pretty vanilla code that invites people to register for  a fictitious Windows 8 workshop that I am hosting. If you scan the code you will see I reference CSS, JavaScript and jQuery.

<html> 
<head> 
    <title>Beginning Windows 8 Workshop</title> 
    <link href="Site.css" rel="stylesheet" type="text/css" /> 
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script>

    <script type="text/javascript"> 
        $(document).ready( 
            function () { 
                $('#animate') 
                    .animate({ width: '+=150px' }, 2000) 
                    .animate({ width: '-=150px' }, 2000) 
            }); 
    </script>

    <script type="text/javascript"> 
        function ShowDate() { 
            var mydate = new Date(); 
            var year = mydate.getYear(); 
            if (year < 1000) { 
                year += 1900 
            } 
            var day = mydate.getDay(); 
            var month = mydate.getMonth(); 
            var daym = mydate.getDate(); 
            if (daym < 10) { 
                daym = "0" + daym; 
            } 
            var montharray = new Array("January", "February", "March", "April", "May", "June", 
                "July", "August", "September", "October", "November", "December"); 
            document.write(montharray[month] + " " + daym + ", " + year) 
        } 
    </script> 
</head> 
<body> 
    <h4> 
        <script type="text/javascript">ShowDate()</script> 
    </h4> 
    <div id="animate"> 
        <img src="windows8logo.jpg" alt="Windows 8 logo" /></div> 
    <h2> 
        Beginning Windows 8 Workshop 
    </h2> 
    <p> 
        <h3> 
            <b><u>Details:</u></b></h3> 
        <br /> 
        Holiday Inn<br /> 
        Grand Ballroom<br /> 
        123 Anylane Road<br /> 
        AnyTown<br /> 
        AnyProvince<br /> 
        A1A 1A1<br /> 
        Canada<br /> 
        <br /> 
        Friday July 27, 2012<br /> 
        Event starts at 6 pm 
    </p> 
    <p> 
        Seating is limited so act fast! 
    </p> 
    <p> 
        Please register below for my Windows 8 Workshop for beginners: 
    </p> 
</body> 
</html>

I am using JavaScript to show the current date on the page and jQuery to animate the Windows 8 logo upon $(document).ready. I have placed both of these client-side scripting items on the page to show that they can work on Site44 and that they can combined if needed. If you find though that one item is not responding you might need to use jQuery.noConflict to return control of the $ back to the other library.

The rendered HTML page will look like this:

HTML Page

This page is almost done but I need to add in my Google document. We will build this now to complete the site.

To create our registration form navigate to the Google Drive website. Click the red Create button on the site and choose Form. You will then get a template similar to this in which two fields are already created:

Empty Form

We can then edit this form to add a title and as many sections as needed. You can also select various input methods including text, checkbox and radio button under Question Type. Fields can also be marked as required to ensure a successful submission. To add subsequent sections click the Add Item button in the upper left. For my site I wish to collect the following items from each registrant:

  • First Name
  • Last Name
  • Email
  • Phone Number
  • Company
  • Poll – Is your company planning to switch to Windows 8?

The finished form will then look something like this:

Finished Form

The title you place on your Form page is the subsequent title of the file. If you close the form editor and return to your Google Drive page you will see the registration form you created in your list of documents. Clicking on the form will take you to the responses page.

Form Spreadsheet

This page is effectively an Excel spreadsheet. Notice how each field on your form is a column on the sheet. Every registration will be contained in a single record in this document. Once I have closed registration for this event I can then go to File | Download as to export all the responses to any file type listed there. If I choose something like .xls I could then use this spreadsheet to track attendance at my event. To edit the form or add additional fields just click Form | Edit form. Use this Help Center for more information on Google Docs.

Now that our Google form is ready we can embed the form’s link in our HTML page. This will make the form render on our registration page so that prospective registrants can start signing up for my course. To embed a Google document you need to find the key to the document. To find the link to our form click Form | Embed this form in a webpage. A dialog box will appear with an IFRAME link. Copy this link and paste it into your HTML page wherever you want your form to appear. In my HTML page I am pasting it at the bottom as the last paragraph. The IFRAME’s source attribute looks like this:

src="https://docs.google.com/spreadsheet/embeddedform?formkey=KEYVALUE
width="760" height="689" frameborder="0" marginheight="0" marginwidth="0"

Your form will appear at the bottom of the page like this:

HTML Page With Form

Notice though the title we gave the form appears on the page. As well, the default width has pushed the form off to the left and is out of skew with the centered text on my page. I also get a vertical scroll bar. I will adjust the width to be 400px and I will append &ttl=0 to the src attribute of the IFRAME which will hide my form’s title on the page. (See more examples here of how else to modify Google Docs.)

My IFRAME source attribute now looks like this:

src="https://docs.google.com/spreadsheet/embeddedform?formkey=KEYVALUE&ttl=0" 
width="400" height="689" frameborder="0" marginheight="0" marginwidth="0"

And my page looks like this:

HTML Page With Form Modified

The next step we need to do is sign up of for Site44. To do this we will go to Site44.com. Make sure you have created and are logged into you Dropbox account. On the Site44 page you will see a button called “Sign in with Dropbox to get started.” This will allow Site44 to create a trusted link with your Dropbox account. Note though that you are NOT giving them access to your entire Dropbox contents. They will only create and share one folder that is necessary to build your websites.

Once the link is made you will see a page called Your Websites. Click the Create a new website button to start building your first site. A dialog box will appear and on this page you can create a free site44.com page or you can use a custom domain if you own one. We will choose a free site for this demo. I will use the site name windows8workshop.site44.com. I did not include the words “Beginner” to my site name so as to keep the webpage generic. This way if I want to add more advanced workshops later on I can keep my same site but just update my registration page as needed.

Once the site is created Site44 takes me to my new webpage. The page contains some default text including the URL of the site and where it is housed on Dropbox.

Website Default Page

If we now move to our Dropbox account we can see that Site44 has created a new root folder called Apps. If we drill down into this folder you will a site44 folder and then a folder for your new webpage. Within this page there will be an index.html file. This is the default page shown above. You can edit this page or remove it all together.

Now depending on if you have installed Dropbox onto your computer or not (if not you can use the web interface) upload your HTML page and any resource files you might need to run your site. If your site is large enough you can create subfolders to house your images or style sheets if you want but just keep in mind that you will also need to update your source paths in your web page. My site folder now looks like this:

Dropbox Folder

When we return to windows8workshop.site44.com we get a 404 error as I have removed the index.html file. I could use a landing page to redirect users but for this demo we can just go right to our new page at windows8workshop.site44.com/Registration.htm We will now see the following:

Complete Website

And if I register myself on the site my Google Docs form responses page will display my registration like this:

Form Spreadsheet With Entry

So, in this tutorial we saw how we could use Dropbox, Site44.com and Google Docs/Google Drive to create a quick registration site. We were able to incorporate both JavaScript and jQuery into the site as well as CSS. Let me know what other creative uses you can think of for using Site44 by leaving a comment below.

Sample Code

Export an ODBC Data Source from the registry

I recently found myself needing to do some Crystal Reports testing on a virtual machine. The tests were successful on my laptop but we use a  virtual machine running Windows Server 2008 R2 and IIS7 as a clean environment for testing. With these tests we were using both ODBC and SQL OLE DB connections to our database. The OLE DB connections were easy enough to replicate but we wanted to make sure our ODBC settings matched my laptop environment. To do this we used the Export feature in the system registry of my Windows 7 laptop.

Before I demonstrate this though I should explain what ODBC is. Open Database Connectivity (ODBC)  is a standard way for connecting to databases. ODBC and the associated driver can connect to a database regardless of the database manufacturer or the operating system on which it runs.

I will demonstrate the steps below on how to run the export.

1. First we need to see which ODBC connections we want to move. To view the existing ODBC connections we can open the ODBC Data Source Administrator. To do this click the Start button and type “ODBC” into “Search programs and files” on the Start Menu. Click “Data Sources (ODBC)” to run the program. It can also be launched from Administrative Tools | Data Sources (ODBC) if it is enabled on your machine. A tabbed dialog box will appear. Most of your ODBC connections should be housed under the User DSN tab.

2. To begin the export process we need to start the Registry Editor. To do this we can search “regedit” from the Start Menu and click Regedit.exe to begin. Another way is to launch the Run Command, enter “regedit” into the dialog and hit OK.

3. You  should now be within the Registry Editor. ODBC Data Sources are stored as keys within the Windows registry. Fortunately they are easy to retrieve. Your DSNs will be housed in two separate spots on Windows 7. (Other operating systems tend to place these in different files so you may need to hunt around.)

    User DSNs: Computer\HKEY_CURRENT_USER\Software\ODBC\ODBC.INI

System DSNs: Computer\HKEY_LOCAL_MACHINE\Software\ODBC\ODBC.INI

Registry Editor

4. Once you have found the correct folder you can now export the desired connection(s). Right click the ODBC.INI folder and select Export to copy every ODBC key in the folder. You can also choose a more granular level of exporting by selecting one DSN within the folder at a time. Unfortunately  the CTRL key cannot be used to select multiple files for one export.

Registry Export

A dialog window will appear. You can choose to export it in multiple file types (although .reg is the standard) and where to save the exported file. You can also select what you want included in the file through the Export Range. The option defaults to “Selected branch” which means you only get the DSN properties listed in the key. You can also select “All” and this will export every registry key in your system. A caveat though – when exporting using All within the Export Range it exported a file containing 3, 907, 557 rows of data. (I ran it twice to be sure this was correct). If you do not have many DSNs to move you might be better off to export each DSN individually.

Registry Export Dialog

Once the Export is saved to disk it will create a .reg file. This file can be opened and examined with a text editor like Notepad. Within the file you will see the various properties of a DSN like server and database names, as well as the selected database driver.

Exported Registry File

With the .reg file open you will now need to modify the file. As you have seen above when you export the ODBC Data Source you only get the DSN properties. However, when you insert this code into the registry on the target machine the DSN will be inserted into the registry but will unavailable elsewhere. To ensure you will have access to the DSN within your Crystal Report file, the ODBC Data Source Administrator and other places you are using ODBC Data Sources you will need to prepend the following code to the file:

[HKEY_CURRENT_USER\Software\ODBC\ODBC.INI\ODBC Data Sources]
"DSN name"="SQL Server"

Modify the “DSN name” to match the name of the ODBC Data Source folder you exported.

Modified Exported Registry File

5. You can now copy the .reg file to the destination computer for installation. Before you install though you might want to open the file and compare the DSN properties. It might be possible the target computer contains different settings than the export file. You can edit the .reg file to match before deploying the file.

6. To insert the values on the target computer open the ODBC Data Source Administrator and select File | Import… to browse to the file. Click Open to run the process. You can also simply double-click the .reg file and it will install the values into the correct locales.

Registry Import

7. The last step is to verify the install. Open the Registry Editor on the destination computer and navigate to the correct DSN folder path. Confirm that your ODBC Data Source is listed in the folder. Close the ODBC Data Source Administrator and re-open it to confirm they are accessible there as well. You can then tweak the DSN further by using the Configure button if need be.

ODBC Data Source Administrator

That is it in a nutshell. In this tutorial we have exported ODBC Data Source connections between two computers running different Microsoft operating systems. We saved ourselves time and headaches by ensuring our connections are identical between the two machines.

Windows Phone 7 sample About Page

Creating an About Page for our apps is probably one of the last things we do as developers. Although it is not required by Microsoft for an app’s acceptance into the Windows Phone Marketplace an About Page is a good idea as it allows you to house all the information someone downloading an app looks for. In this post I will show you my sample About Page that I have used on many of my apps and provide you with the code to download so you can add it to your apps quickly and easily.

When I build apps I favour the Pivot Application template. I find that it allows users to navigate around my app effortlessly. As such my About Page example will be for a Pivot application but with minor modifications this code could be added to any WP7 app.

This is the Pivot Item code for my MainPage.xaml Pivot Control:

Windows Phone 7 About Page Xaml

To use the code as is you only need to input your app’s title and your name at the bottom where you declare your copyright. You can also modify this code if you wish to move items around or change your ownership declaration.

And here is the code behind:

Windows Phone 7 About Page Code Behind

And here are the using statements:

Windows Phone 7 About Page Usings

 

To use the code behind from the example you will need to add both the Microsoft.Phone.Tasks and the System.Reflection namespaces.

As you can see the help button generates an email to an email address of your choice. This method needs you to only set your email address and your application title in the subject line of the method. The method pulls the current major and minor version numbers out of the Assembly property in the AssemblyInfo.cs file.

If you wish to use the version number in the WMAppManifest.xml instead you need to add a reference to “System.Xml.Linq” in your project references and then add the following using statement: “using System.Xml.Linq;”. From there you can draw the version number out with the following piece of code:
string Version = XDocument.Load(“WMAppManifest.xml”).Root.Element(“App”).Attribute(“Version”).Value;

You will want to provide a support link as it allows users to notify you if there is a problem. They will also email you to helpfully suggest improvements to your app so that their experience will be better. It is like giving your app to a focus group!

Both the MarketplaceReviewTask and MarketplaceSearchTask use the Microsoft.Phone.Tasks namespace. Through this reference users can both rate your current app and also search for your other apps. For additional information on this namespace check out this link. There are many more classes that you can tap into with this namespace.

Allowing users to rate and review your app from the About Page is a great idea as they can do it while they are thinking of it. Their ratings will then increase your standing in the Marketplace and in the developer community as you are seen as someone who develops quality applications.

Windows Phone 7 About PageAs you can see from the finished product on the left that creating a functional About Page is a pretty easy task and it provides a benefit to both the user and yourself.

You can download the code from this article here and from my GitHub account.