Here it is, the new WP7 Developer roundup for 11/25/2010! This time I provide more links then ever 🙂

Windows Phone 7 Development Best Practices Wiki

Windows Phone 7 Development for absolute beginners (channel9)

Is my XNA Game dead yet?! (Dark Genesis)

There and back again “A tombstoning Tale” – The returning of an Application (Dark Genesis)

My Photo App – sample project (Jeff Wilcox)

The taming of the phone [new SetterValueBindingHelper] (Delay)

Windows Phone 7 with Expression Blend (Chris Koenig)

Use concurrent programming techniques (Silveright Hack)

Use ShellTileSchedule to easily update your live-tiles (Kevin D. Holes)

How to: Encode a JPEG for Windows Phone and Save to Pictures Library (MSDN)

Windows Phone 7 Line of Business App dev: Network awareness (Rob Tiffany)

Advertisements

As the title suggests, this blog post is all about bulding a UserControl for Silverlight, Windows Phone 7 or WPF development projects. I want to show this with a really simple example, inspiried by Silverlight in Action 4 by Pete Brown!

Open up Visual Studio and choose the class library project template for your target (e.g. SL or WP7)

In the solution explorer, rightclick on your project and add a new item –> <silverlight or WP7,…> user control! Now you see an almost empty xaml-file of your control. For this example we simple build a lockable textbox, so delete the the default grid and add a StackPanel and put a TextBox and a CheckBox in it.

Like in the picture, give your Text- and CheckBox a name. Cause we`re building a “lockable” Textbox, we want to set the IsReadOnly-Property of the TextBox to TRUE, if the user checks the CheckBox. This for example can be accomplished by DependencyProperties and binding in the code-behind or by writing  a simple converter-class, which we will be doing!

Now add a new class to your project and name it IsLockedConverter.cs or any other name you wish :). Cause it`s a converter we have to inherit from the IValueConverter interface, which provides us two methods, Convert() and ConvertBack(). We also have to inherit from the TextBox class, because we want to have access to the IsReadOnly-property of our TextBox.

In the Convert() method we have to return wether the given value is true or false. Just have a look at the implementation.

After this, we only have to add our new converter to our UserControl and using it! The first step is to add the appropriate xmlns in the header of the UserControl, in this case its something like this:

xmlns:converters=”clr-namespace:CustomControls.Converters”

Maybe your namespace is slighly different than mine. The second step is to add our converter to the UserControl.Resources specified by x:Key for “calling” it later on.

<UserControl.Resources>

<converters:IsLockedConverter x:Key=”IsLockedConverter” />

</UserControl.Resources>

You can name your converter whatever you like. So now the interesting part of using our converter. Go to your TextBox declaration in the xaml and add the IsReadOnly-Property and add the following binding:

…IsReadOnly=”{Binding ElementName=myCheckBox, Path=IsChecked, Converter={StaticResource IsLockedConverter}}”

With this line of code you bind the CheckBox to the IsReadOnly-Property of your TextBox. ElementName is the specified name of your Checkbox and the Path is the CheckBoxs property. After the Path you see the “Converter=” there you have to add our converter as a static resource. So whenever the user checks the checkbox this boolean value is passed to our converter and sets the IsReadOnly property of the textbox.

That`s easy isn`t it?! I hope that this is useful for the one or the other.

—UPDATE

You can grab the code here on GitHub…  https://github.com/cordellcp3/Various/tree/master/CustomControls/

Here it is, the third WP7 Developer Roundup which aggregates information of interest to Windows Phone 7 developers. I want to share every good article, link or video which I come across over the week. I was really busy this week so…

Loading quickly on Windows Phone 7 – Twitter example [eng] (identitymine)

Inside Windows Phone #11 Obfustication and Analytics [eng] (channel9)

How to move your line of business apps to phone + cloud [eng] (Bruce Kyle)

More under the hood, but hidden or locked [eng] (xda developers)

At the weekend I spend some time testing aroung with geolocation and coordinates wihtin Windows Phone 7 development  and wrote a Method,  which calculates the distance of two given geocoordinates (Point A –> LatitudeA | LongitudeA and Point B –> LatitudeB | LongitudeB ) in kilometer (km).

It works just fine and  I want to share the code with everyone, so here it is

Grab the code here –> https://gist.github.com/61dc8a65f9fc8fb662e3

Maybe it`s helpful for one or the other.

Here it is, the second WP7 Developer Roundup which aggregates information of interest to Windows Phone 7 developers. I want to share every good article, link or video which I come across over the week…

Improving Windows Phone 7 Application Performance [eng] (David Anson)

Silverlight for Windows Phone Toolkit – Nov 2010 [eng] (CodePlex)

WP7 Serialization Comparison [eng] (Kevon Marshall)

How I made the ‘myChannel9′ wp7 app (source code included) – Part 1 [eng] (Sigurd Snorteland)

Sterling Isolated Storage Database with LINQ for Windows Phone 7 [eng] (CodePlex)

Windows Phone 7 Fundamentals [ger] (Sascha Wolter)

Silverlight Windowless-Mode?

3. November 2010

When you want to embed HTML or something like that in a IFrame wihtin a Silverlight application and you come across an error which says that you have to change the windowless parameter to true  and one don`t know where to do this. Just open up your …TestPage.aspx or …TestPage.html file, which hosts your Silverlight  application.

Scroll down until you find <div id=”silverlightControlHost”> and simply add the windowless parameter like so:

Est voila, that`s all one got to do…