Posts
133
Comments
328
Trackbacks
0
February 2011 Entries
Dream.In.Code Podcast 15 with Michael Crump

I was recently interviewed by Dennis Delimarsky for his podcast titled “Dream.In.Code”. We talked for about an hour on all things Silverlight and Windows Phone 7. Dennis asked a lot of great questions and I thoroughly enjoyed chatting with him. Check out the interview and let me know what you think.

Listen to the podcast.

Dream.In.Code Website

image

Thanks again to Dream In Code for this opportunity. 

alt Subscribe to my feed

Posted On Wednesday, February 23, 2011 8:59 AM | Feedback (0)
Attaching a Command to the WP7 Application Bar.

One of the biggest problems that I’ve seen with people creating WP7 applications is how do you bind the application bar to a Relay Command. If your using MVVM then this is particular important. Let’s examine the code that one might add to start with. 

<phone:PhoneApplicationPage.ApplicationBar>
    <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
        <shell:ApplicationBarIconButton x:Name="appbar_button1" IconUri="/icons/appbar.questionmark.rest.png" Text="About">
            <i:Interaction.Triggers>
                <i:EventTrigger EventName="Click">
                    <GalaSoft_MvvmLight_Command:EventToCommand Command="{Binding DisplayAbout, Mode=OneWay}" />
                </i:EventTrigger>
            </i:Interaction.Triggers>

        </shell:ApplicationBarIconButton>
        <shell:ApplicationBar.MenuItems>
            <shell:ApplicationBarMenuItem x:Name="menuItem1" Text="MenuItem 1"></shell:ApplicationBarMenuItem>
            <shell:ApplicationBarMenuItem x:Name="menuItem2" Text="MenuItem 2"></shell:ApplicationBarMenuItem>
        </shell:ApplicationBar.MenuItems>
    </shell:ApplicationBar>
</phone:PhoneApplicationPage.ApplicationBar>

Everything looks right. But we quickly notice that we have a squiggly line under our Interaction.Triggers. The problem is that the object is not a FrameworkObject. This same code would have worked perfect if this were a normal button.

image

OK. Point has been proved. Let’s make the ApplicationBar support Commands. So, go ahead and create a new project using MVVM Light. If you want to check out the source and work along side this tutorial then click here

7 Easy Steps to have binding on the Application Bar using MVVM Light (I might add that you don’t have to use MVVM Light to get this functionality, I just prefer it.)

image

1) Download MVVM Light if you don’t already have it and install the project templates. It is available at http://mvvmlight.codeplex.com/.

2) Click File-New Project and navigate to Silverlight for Windows Phone. Make sure you use the MVVM Light (WP7) Template.

SNAGHTML1683fc7d

3) Now that we have our project setup and ready to go let’s download a wrapper created by Nicolas Humann here, it is called Phone7.Fx. After you download it then extract it somewhere that you can find it. This wrapper will make our application bar/menu item bindable.

4) Right click References inside your WP7 project and add the .dll file to your project.

image

image

5) In your MainPage.xaml you will need to add the proper namespace to it. Don’t forget to build your project afterwards.

xmlns:Preview="clr-namespace:Phone7.Fx.Preview;assembly=Phone7.Fx.Preview" 

6) Now you can add the BindableAppBar to your MainPage.xaml with a few lines of code. 

<Preview:BindableApplicationBar x:Name="AppBar" BarOpacity="1.0"  >
    <Preview:BindableApplicationBarIconButton Command="{Binding DisplayAbout}" IconUri="/icons/appbar.questionmark.rest.png" Text="About" />
    <Preview:BindableApplicationBar.MenuItems>
        <Preview:BindableApplicationBarMenuItem  Text="Settings" Command="{Binding InputBox}" />
    </Preview:BindableApplicationBar.MenuItems>
</Preview:BindableApplicationBar>
So your final MainPage.xaml will look similar to this: NOTE: The AppBar will be located inside of the Grid using this wrapper.  
<!--LayoutRoot contains the root grid where all other page content is placed-->
<Grid x:Name="LayoutRoot"
      Background="Transparent">
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto" />
        <RowDefinition Height="*" />
    </Grid.RowDefinitions>

    <!--TitlePanel contains the name of the application and page title-->
    <StackPanel x:Name="TitlePanel"
                Grid.Row="0"
                Margin="24,24,0,12">
        <TextBlock x:Name="ApplicationTitle"
                   Text="{Binding ApplicationTitle}"
                   Style="{StaticResource PhoneTextNormalStyle}" />
        <TextBlock x:Name="PageTitle"
                   Text="{Binding PageName}"
                   Margin="-3,-8,0,0"
                   Style="{StaticResource PhoneTextTitle1Style}" />
    </StackPanel>

    <!--ContentPanel - place additional content here-->
    <Grid x:Name="ContentGrid"
          Grid.Row="1">

        <TextBlock Text="{Binding Welcome}"
                   Style="{StaticResource PhoneTextNormalStyle}"
                   HorizontalAlignment="Center"
                   VerticalAlignment="Center"
                   FontSize="40" />

    </Grid>
    <Preview:BindableApplicationBar x:Name="AppBar" BarOpacity="1.0"  >
        <Preview:BindableApplicationBarIconButton Command="{Binding DisplayAbout}" IconUri="/icons/appbar.questionmark.rest.png" Text="About" />
        <Preview:BindableApplicationBar.MenuItems>
            <Preview:BindableApplicationBarMenuItem  Text="Settings" Command="{Binding InputBox}" />
        </Preview:BindableApplicationBar.MenuItems>
    </Preview:BindableApplicationBar>
</Grid>

7) Let’s go ahead and create the RelayCommands and write them up to a MessageBox by editing our MainViewModel.cs file.

public class MainViewModel : ViewModelBase
 {
     public string ApplicationTitle
     {
         get
         {
             return "MVVM LIGHT";
         }
     }

     public string PageName
     {
         get
         {
             return "My page:";
         }
     }

     public string Welcome
     {
         get
         {
             return "Welcome to MVVM Light";
         }
     }

     public RelayCommand DisplayAbout
     {
         get;
         private set;
     }

     public RelayCommand InputBox
     {
         get; 
         private set;
     }

     /// <summary>
     /// Initializes a new instance of the MainViewModel class.
     /// </summary>
     public MainViewModel()
     {
         if (IsInDesignMode)
         {
             // Code runs in Blend --> create design time data.
         }
         else
         {
             DisplayAbout = new RelayCommand(() =>
                                                 {
                                                     MessageBox.Show("About box called!");
                                                 });
             InputBox = new RelayCommand(() =>
                                             {
                                                 MessageBox.Show("settings button called");
                                             });
         }
     }
If you run the project now you should get something similar to this (notice the AppBar at the bottom): 

SNAGHTML16881ecc

Now if you hit the question mark then you will get the following MessageBox:

image

The MenuItem works as well so for Settings:

SNAGHTML17405cd8

image

As you can see, its pretty easy to add a Command to the ApplicationBar/MenuItem. If you want to look through the full source code then click here

alt Subscribe to my feed

Posted On Tuesday, February 22, 2011 7:07 AM | Feedback (5)
Having Fun with Coding4Fun’s Windows Phone 7 Controls

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.

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

After you have downloaded it then 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 DLL’s by right clicking on the References folder and clicking “Add references”.

image

 

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" 

And then the code inside your Grid or wherever you want the Loading screen placed.

<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.

 

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.

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();

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

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 its 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!

alt Subscribe to my feed

Posted On Monday, February 14, 2011 6:32 AM | Feedback (1)
What developer conferences are you going to this year?

image

This short list is what I consider to be the “cream-of-the-crop” in developer conferences. This is also a list of the conferences that I plan on attending in 2011. If you feel your conference is just as good, then shoot me an email at [michael[at]michaelcrump[dot]net, and if possible I will check it out.

 

image

In-Person Event

Las Vegas on April 18th-22nd, 2011
Redmond on October 17th-21st, 2011
Orlando on December 5th-9th, 2011

Visual Studio Live – I attended this event in November of last year and blogged about my experience. I am also planning on going back to the Orlando session in December of this year. So what did I like the most about this event? Being able to interact one-on-one with a majority of the speakers. If you read my blog post then you will see a list of the speakers that I met up with. I also made a lot of great connections with other professional developers all over the world. They are having an event in Las Vegas on April 18th-22nd. I noticed at this event that they have added a new track on mobile. Being a big fan of mobile, I feel that this is a great move. They also have a great selection for Silverlight Developers including Billy Hollis and Rocky Lhotka. For the full lineup of conference tracks, sessions and speakers visit http://bit.ly/VSLiveTrks. If you are interested in this then you can register here by February 16th. I must add that you can save $300 bucks by getting the early-bird special.

 

image

Virtual Conference

SSWUG (DBTechCon) - holds the largest virtual conference in the information technology industry. It is also special to me because they selected a majority of my Silverlight content for the April conference. No traveling fees and all of the sessions are recorded so you can watch them on-demand for $189 bucks (early-bird special). For the entire speaker list then click here. The session list has also been published. If you are interested in this then you can register here and don’t forget to use VIP Code “SP11DBTechMC” to save $30 on the overall purchase.

 

image

In-Person Event

Knoxville, TN on June 3rd/4th 2011.

Codestock.org – If you live in the South then you have heard of CodeStock. To my knowledge, they have only had 3 events so far and they were a huge success. It was such a success that after the last event, everyone was telling me how good it was and how much they enjoyed it. They currently have a call for speakers going on right now, so if you have sessions then be sure to submit yours. So, what makes them stand out? Well for starters Michael Neal (organizer) developed an open API so conference attendees could build their own apps for the sessions. They also encouraged their speakers to go to other sessions instead of stay in a “speaker-room”. Another cool feature is that they are uploading videos from the conference so everyone can benefit. They are currently looking for sponsorship, so help out if you can.  

image

In-Person Event

Unknown at this point

PDC 11 – OK, so the logo should be pdc11 but its not out yet. This event was located on Microsoft’s campus in Redmond, WA for pdc 10. They have not announced the location for 2011 yet. It is probably one of the most well known conferences for developers to attend. One of the big perks from this event is that you typically come away with free stuff. In 2010 they gave away Windows 7 Phones. I remember years earlier they gave away laptops. This of course isn’t the only reason to go, you may get to tour the Microsoft campus. Since pdc is a huge event, you can view all the events for free. Mike Taulty created a nice Silverlight application that consumes the OData feed. You can download it here.

If everything goes as planned, I will be at all of these events. If you plan on going then send me a tweet and we will do lunch or dinner. I love meeting new developers and talking .net.

alt Subscribe to my feed

Posted On Thursday, February 10, 2011 7:21 AM | Feedback (3)
New XAML-Based User Group started in Birmingham, Alabama.

I’m pleased to announce that a new XAML-Based User Group has started in Birmingham, Alabama. The group is being hosted by Michael Crump and Jonathan Marbutt. The reason is very simple: we feel that Birmingham needs a fresh start. We are both very passionate about .NET and are hoping to share our experiences with the community. We have created a site (http://allaboutxaml.net) and our first meetup is now scheduled. We are here to discuss all things that have to do with xaml. This includes Silverlight, WPF, Windows Phone 7, Surface, Lightswitch and Silverlight with SharePoint 2010.

We:

  • believe strongly in xaml and are passionate about what we talk about.
  • believe in an open-forum.
  • believe a user group should be FUN as well as educational.
  • do not claim to be an expert on anything, we are here to share.
  • record every presentation and put it on the web for others to benefit.
  • meet monthly but are flexible on the actual date.
  • have families and our meetings start and stop on time.
  • welcome new speakers.

Our first meeting is going to be on February 15th, 2011 (6PM), at Logan's on HWY 280. It is going to be more of a meetup than a meeting. I would like to discuss current xaml-based projects that you are working on and get to know one another. If you are interested in coming then please sign up here so that we know how many to expect.

Please visit our site to find out more about us: http://allaboutxaml.net.

Posted On Monday, February 07, 2011 10:16 AM | Feedback (3)
Quick run through of the WP7 Developer Tools January 2011

In case you haven’t heard the latest WP7 Developers Tool update was released yesterday and contains a few goodies. First you need to go and grab the bits here.

You can install them in any order, but I installed the WindowsPhoneDeveloperResources_en-US_Patch1.msp first.

SNAGHTML11b99e

Then the VS10-KB2486994-x86.exe.

SNAGHTML1249bc

They install silently. In other words, you would need to check Programs and Features and look in Installed Updates to see if they installed successfully. Like the screenshot below:

SNAGHTML432438a

Once you get them installed you can try out a few new features.

Like Copy and Paste.

Just fire up your application and put a TextBox on it and Select the Text and you will have the option highlighted in red above the text.

SNAGHTML42fc028

Once you select it you will have the option to paste it. (see red rectangle below).

SNAGHTML434e748

Another feature is the Windows Phone Capability Detection Tool – This tool detects the phone capabilities used by your application. This will prevent you from submitting an app to the marketplace that says it uses x feature but really does not.

How do you use it?

Well navigate out to either directory:

  • %ProgramFiles%\Microsoft SDKs\Windows Phone\v7.0\Tools\CapDetect

  • %ProgramFiles (x86)%\Microsoft SDKs\Windows Phone\v7.0\Tools\CapDetect

SNAGHTML2e6fa4
and run the following command: 
CapabilityDetection.exe Rules.xml YOURWP7XAPFILEOUTPUTDIRECTORY
So, in my example you will see my app only requires the ID_CAP_MICROPHONE.
SNAGHTML447d667

Let’s see what the WmAppManifest.xml says in our WP7 Project:

image

image

Whoa! That’s a lot of extra stuff we don’t need. We can delete unused capabilities safely now.

image

Some of the other fixes are: (Copied straight from Microsoft)

  • Fixes a text selection bug in pivot and panorama controls. In applications that have pivot or panorama controls that contain text boxes, users can unintentionally change panes when trying to copy text. To prevent this problem, open your application, recompile it, and then resubmit it to the Windows Phone Marketplace.
  • Windows Phone Connect Tool – Allows you to connect your phone to a PC when Zune® software is not running and debug applications that use media APIs. For more information, see How to: Use the Connect Tool.
  • Updated Bing Maps Silverlight Control – Includes improvements to gesture performance when using Bing™ Maps Silverlight® Control.
  • Windows Phone Developer Tools Fix allowing deployment of XAP files over 64 MB in size to physical phone devices for testing and debugging.

That’s pretty much it. Thanks again for reading my blog!

alt Subscribe to my feed

Posted On Saturday, February 05, 2011 4:18 PM | Feedback (1)
Review of Samsung Focus Windows Phone 7

I recently acquired a Samsung Focus Windows Phone 7 device from AT&T and wanted to share what I thought of it as an end-user.

Before I get started, here are several of my write-ups for the Windows Phone 7. You may want to check out the second article titled: Hands-on WP7 Review of Prototype Hardware.

From start to finish with the final version of Visual Studio Tools for Windows Phone 7
Hands-on : Windows Phone 7 Review on Prototype Hardware.
Deploying your Windows Phone 7 Application to the actual hardware.
Profile your Windows Phone 7 Application for Free
Submitting a Windows Phone 7 Application to the Market.

Samsung Focus i917

Phone Size: Perfect! I have been carrying around a Dell Streak (Android) and it is about half the size. It is really nice to have a phone that fits in your pocket without a lot of extra bulk. I bought a case for the Focus and it is still a perfect size.  The phone just feels right.
Screen: It has a beautiful Super AMOLED 480x800 screen. I only wish it supported a higher resolution. The colors are beautiful especially in an Xbox Live Game.  
3G: I use AT&T and I've had spotty reception. This really can't be blamed on the phone as much as the actual carrier.
Battery: I've had excellent battery life compared to my iPhone and Android devices. I usually use my phone throughout the day on and off and still have a charge at the end of the day. 
Camera/Video: I'm still looking for the option to send the video to YouTube or the Image to Twitter. The images look good, but the phone needs a forward facing camera. I like the iPhone/Android (Dell Streak) camera better.
Built-in Speaker: Sounds great. It’s not a wimpy speaker that you cannot hear. 
CPU: Very smooth transitioning from one screen to another. The prototype Windows Phone 7 that I had, was no where near as smooth. (It was also running a slower processor though).
OS: I actually like the OS but a few things could be better.

CONS:

  1. Copy and Paste (Supposed to come in the next update)
  2. We need more apps (Pandora missing was a big one for me and Slacker’s advertisement sucks!). As time passes, and more developers get on board then this will be fixed.
  3. The browser needs some major work. I have tried to make cross-platform (WP7, Android, iPhone and iPad) web apps and the browser that ships with WP7 just can’t handle it. 
  4. Apps need to be organized better. Instead of throw them all on one screen, it would help to allow the user to create categories.

PROS:

  1. Hands down the best gaming experience on a phone. I have all three major phones (iphone, android and wp7). Nothing compares to the gaming experience on the WP7.
  2. The phone just works. I’ve had a LOT of glitches with my Android device. I’ve had maybe 2 with my WP7 device. Exchange and Office support are great.
  3. Nice integration with Twitter/Facebook and social media.
  4. Easy to navigate and find the information you need on one screen.

Let’s look at a few pictures and we will wrap up with my final thoughts on the phone.

WP7 Home Screen.


image

Back of the phone is as stylish.

image

It is hard to see due to the shadow but it is a very thin phone.

image

What’s included?

  • Manuals
  • Ear buds
  • Data Cable plus Power Adapter
  • Phone

Click a picture to enlarge

imageimageimage

So, what are my final thoughts on the Phone/OS?

I love the Samsung Focus and would recommend it to anyone looking for a WP7 device. Like any first generation product, you need to give it a little while to mature. Right now the phone is missing several features that we are all used to using. That doesn’t mean a year from now it will be in the same situation. (I sure hope we won’t). If you are looking to get into mobile development, I believe WP7 is the easiest platform to develop from. This is especially true if you have a background in Silverlight or WPF.

 

alt Subscribe to my feed

Posted On Thursday, February 03, 2011 6:28 AM | Feedback (6)
Tag Cloud