Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Having Fun with Coding4Fun’s Windows Phone 7 Controls

0.00/5 (No votes)
11 Mar 2011 1  
A look at the new Windows Phone 7 controls by Coding4Fun

Introduction

image

I’m a big believer in having a hobby project as you can probably tell from the first sentence in my “personal webpage using Silverlight” article. One of my current hobby projects is to re-do my current WP7 application in the marketplace. I knew up front that I needed a “Loading” animation and a better “About” box. After starting to develop my own, I noticed a great set of WP7 controls by Coding4Fun and decided to use them in my new application. Before I go any further, they are FREE and Open-Source.

The full source code for the project can be downloaded from here.

Get the Bits

It is really simple to get started, just go to the CodePlex site and click the download button.

After you have downloaded it, extract it to a Folder and you will have 4 DLL files. They are listed below:

image

Now create a Windows Phone 7 Project and add references to the DLLs by right clicking on the References folder and clicking “Add references”.

image

ProgressOverlay Animation

After adding the references, we can get started. I needed a ProgressOverlay animation or “Loading Screen” while my RSS feed is downloading.

SNAGHTMLc1ceea1

Basically, you just need to add the following namespace to whatever page you want the control on:

xmlns:Controls="clr-namespace:Coding4Fun.Phone.Controls;
	assembly=Coding4Fun.Phone.Controls" 
<Controls:ProgressOverlay Name="progressOverlay" >
    <Controls:ProgressOverlay.Content>
        <TextBlock>Loading</TextBlock>
    </Controls:ProgressOverlay.Content>
</Controls:ProgressOverlay>		

Bam, you now have a great looking loading screen. Of course, inside the ProgressOverlay, you may want to add a Visibility property to turn it off after your data loads if you are using MVVM or similar pattern.

A Better "About Box"

Next up, I needed a nice clean “About Box” that looks good but is also functional. Meaning, if they click on my twitter name, web or email to launch the appropriate task.

SNAGHTMLcbf4bf0

Again, this is only a few lines of code:

var p = new AboutPrompt();
p.VersionNumber = "2.0";
p.Show("Michael Crump", "@mbcrump", 
	"michael@michaelcrump.net", @"http://michaelcrump.net");

A nice clean “About” box with just a few lines of code! I’m all for code that I don’t have to write.

The InputBox

It also comes with a pretty sweet InputPrompt for grabbing info from a user:

SNAGHTMLcd1c370SNAGHTMLcd27216

The code for this is also very simple:

InputPrompt input = new InputPrompt();
input.Completed += (s, e) =>
                       {
                           MessageBox.Show(e.Result.ToString());
                       };
 
input.Title = "Input Box";
input.Message = "What does a \"Developer Large\" T-Shirt Mean? ";
input.Show(); 

PhoneHelper Class

I also enjoyed the PhoneHelper that allows you to get data out of the WMAppManifest File very easily.

So for example, if I wanted the Version info from the WMAppManifest file.

image

I could write one line and get it.

PhoneHelper.GetAppAttribute("Version") 

Of course, you would want to make sure you add the following using statement:

using Coding4Fun.Phone.Controls.Data; 

You can’t have all these cool controls without a great set of Converters. The included BooleanToVisibility converter will convert a Boolean to and from a Visibility value. This is excellent when using something like a CheckBox to display a TextBox when it's checked. See the example below:

SNAGHTML11d9642cSNAGHTML11dbaef1

The code is below:

<phone:PhoneApplicationPage.Resources>
    <Converters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
</phone:PhoneApplicationPage.Resources>
<CheckBox x:Name="checkBox"/>
<TextBlock Text="Display Text" Visibility="{Binding ElementName=checkBox, 
	Path=IsChecked, Converter={StaticResource BooleanToVisibilityConverter} }"/> 

That’s not all the goodies included. They also provide a RoundedButton, TimePicker and several other converters. The documentation is great and I would recommend you give them a shot if you need any of this functionality. BTW, thank Brian Peek for his awesome work on Coding4Fun!

Like this article?

alt Subscribe to my feed

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here