Rob Kraft's Software Development Blog

Software Development Insights

Archive for the ‘Windows Phone 7’ Category

How to programmatically make the Windows Phone 7 Keyboard open

Posted by robkraft on May 15, 2011

I wrote a Windows Phone 7 application with a search page.  When a user clicks on the search icon I wanted to take them to the search page, set focus on the text box, and have the on phone keyboard pop open for the TextBox.  Since the TextBox was the only control on the page I figured it would get focus and the keyboard would open up; but it didn’t work that way.  To make it work, I used the Focus event on the TextBox.  The only trick to this is that you can’t call the .Focus on the TextBox in page constructor because the XAML has not all rendered and events are not yet tied to all the page elements.  So, you need to create a load event in the constructor, and have the load event call Focus on your textbox.  This will cause the keyboard to open as soon as someone navigates to the page.

public SearchPage
this.Loaded += new RoutedEventHandler(SearchPage_Loaded);

void SearchPage_Loaded(object sender, RoutedEventArgs e)

Posted in Code Design, Silverlight, Windows Phone 7 | 1 Comment »

BooleanToVisibility Converter – Yes, you must write your own for your Phone

Posted by robkraft on May 6, 2011

You must code your own BooleanToVisibilityConverter in Windows Phone 7 development as of May 2011.  That may change when Silverlight 4 can be used for Phone 7 development.  Until then, I recommend you write your own, and start with a good example like the ones found here:

I spent more time than I expected on this project attempting to use a boolean value in my viewmodel to control the visibility of an error message on the form.  What I learned is that I DO need to write my own Converter class that implements Iconverter.  I had the impression from many blog posts that this was built it, but it is not – at least not in Windows Phone 7 with Visual Studio 2010 after the NoDo updates and all Phone SDK updates available through April of 2010.  I did not have to write my own converter though, I just copied this code I found elsewhere on the net.  Then I had to make 3 entries in my XAML:

  1. xmlns:loc=”clr-namespace:MyAppNamespace” where MyAppNamespace is the namespace over the class containing my converting.  This entry was already in my XAML for other purposes – and of course “loc” is just a variable name that you can replace with anything.
  2. Add this little bit of code in the Xaml after the first big block that imports the namespaces.  The name BooleanToVisibilityConverter needs to be the class name of the class you created for this.

<loc:BooleanToVisibilityConverter x:Key=”BooleanToVisibility” />


  1. Then use it on one to many Visibility properties with code like the following.  In this case, I have a property named SearchFactsFound on my ViewModel.

Visibility=”{Binding SearchFactsFound, Converter={StaticResource BooleanToVisibility}}”

Posted in Silverlight, Windows Phone 7 | 1 Comment »

How to edit your application icons for the application list and tile for Windows Phone 7

Posted by robkraft on April 26, 2011

I hoped to find a totally freeware version of an icon I could use for my Windows Phone 7
application somewhere on the Internet.  I am not a graphics guy and I don’t expect my application to make enough money to justify hiring an artist.  I did find a PNG file that was good enough, but it only came in one size (48X48), not the 62×62 and 173×173 dimensions I needed for the phone.  I decided to try to resize the PNG but it did not resize well by default.  I decided to try again using Paint.Net.  I chose the “Nearest Neighbor” resampling option in the Resize dialog and fortunately this gave me a nicer looking large PNG than the default resampling
options had.

Posted in Windows Phone 7 | Leave a Comment »

How to make your own application icons for Windows Phone 7

Posted by robkraft on April 25, 2011

I searched around the Internet for 48×48 PNG images that I could use for Application Bar Icons on my Windows Phone 7.  I was hoping to find an icon that represented “menu”, but I did not.  Finally, I decided to try to edit something I felt was close and I am glad I did because it was very easy to do.  I obtained a free icon editor called IcoFX from (I almost always download from because they have already ran virus checks against the files they host).  I then opened an existing image and began making the minor edits I desired for my new image.  I made sure that the image was a “True Color”, or “32bit” image.   I saved it as an .ico, then used the Export Image option from the File menu of IcoFX to export it to a .PNG.

Posted in Windows Phone 7 | Leave a Comment »

How to capture screen shots for Windows Phone 7

Posted by robkraft on April 24, 2011

To publish an application to the Windows Phone 7 store you must provide at least one screen capture of your application. I believe the best method to do this is to run your application in the emulator and use the “snipping tool” in Windows 7.

  • Set the zoom size of the emulator to 100%.
  • If the full screen does not fit on your monitor, rotate the emulator 90 degrees to take the screen shot.
  • If your application supports both portrait and landscape orientation, but you want a portrait image, change your code to only support portrait mode long enough to take a screen capture.
  • Use the “Window snip” from the snipping tool and save the image as PNG.
  • Use Paint.Net to rotate the image back to vertical if you had to rotate it for your screen capture.

Posted in Windows Phone 7 | Leave a Comment »

MVVM Rocks! It helped me past a PivotControl bug.

Posted by robkraft on April 24, 2011

MVVM rocks! I thought I would be spending many hours to convert my PivotControl UI to a simple Page UI after I discovered that some PivotControl features don’t work. But the switch took me less than an hour to create 4 new pages and get them all functional. Changing the UI was simple because all of my logic was in my viewmodel. When I bound new forms to my ViewModel to replace the previous PivotControl form, everything just worked. Score a victory for MVVM!
The PivotControl feature that does not work that I needed was the ability to set the Index of the PivotControl and allow the ViewModel to cause navigation to the specified Index. Unfortunately, as of April 2011 in Visual Studio 2010 with Phone 7 it does not matter what value you provide to the SelectedIndex or SelectedItem in the PivotControl, you can only cause the PivotControl to display starting with index zero. I expect this bug will be fixed in the next release of the PivotControl.

Posted in Windows Phone 7 | Leave a Comment »