Friday, March 25, 2011

Hackatopia - MVC 3 JSON Services & WP7

Here's a list of resources for my talk at Hackatopia on March 26.

Sample Project - JSONPhoneApp1


Links

TeamRepository - For Some Test Data
TeamController - For return our test data in JSON
JsonService - For consuming/serializing JSON objects in Win Phone 7
MVVMCommon - A set of common MVVM Classes
TeamWP7 - All the VM's and Services for Consuming our test data
Postifier - Turn an object into a URL Encoded string
JSONView - A Chrome Extension for pretty printing JSON.




Wednesday, March 23, 2011

Gist4u2 - NuGet Console Utilities for Gists

Not many people know this, but I'm actually a powershell ninja from waaayyyy back 

Scriptinggames2007

(that's me in the scoring list, third from the top)

So when I first started playing around with the NuGet Package Manager Console I was quite impressed with the opportunities it presented.

Flash forward to today and I'm preparing for a presentation in an upcoming Chicago Hackatopia Win Phone 7 event where I find myself storing a lot of my code snippets for my presentation in Gists.  That's when I got the idea for Gist4u2; a handy way to insert gists into your code.  

So far, it's been pretty useful for my demonstrations.  Here is a quick example of how I use it.  Let's say I'm starting a new Windows Phone 7 project and I want to add some basic MVVM fundamental code like a ViewModelBase and Commanding classes (DelegateCommand, EventToCommand behavior).

Start a new Win Phone 7 Project, Open the Package Manager Console from the Tools -> Library Package Manager Menu (if you don't have it, Install NuGet through the extension manager)

Packagermanagerconsole

Next, install the Gist4u2 package to add the helper commands into the Console

Install-list-gists

Notice the last Gist there, the 883810, that's what I want.  So I create a new file (hopefully in the future I can create them for you in the project) called MVVMCommon and type Gist-Insert '883810' to insert the contents of my MVVMCommon Gist.

Gist-insert

Bam!  That's it.  Now we have a ViewModelBase and DelegateCommand ready to use in our Windows Phone 7 project.  Now my presentation is going to be much quicker.

Monday, March 21, 2011

HTML5 Boilerplate MVC 3 Site with AppHarbor in 3 Easy Steps

Here's a quick way to get a new .Net MVC 3 site up quickly that incorporates HTML5 Boilerplate patterns and practices.

Step 0: Get Git (If you don't have it)

Git for Windows is available from the msysgit repository on Google Code; this guide was written for the 1.7.4 preview version.

There's even a guide for installing on windows if you need some help.


Step 1:  Create Your AppHarbor Project

Go the the AppHarbor home page and create a new account if you haven't done so yet.  Then click the Create New link on the Applications tab to get started.

Newapp

Once you've got your application created, copy the Repository URL so you can push your source up to your new site.

Gitlink

Step 2:  Create Your MotherEffin HTML5 MVC 3 Site Project

I've created a super easy HTML5 Boilerplate MVC 3 template project that can deploy to AppHarbor with no modifications.  You can get it from the Visual Studio Extension gallery, or through the new project dialog by clicking the Online tab item on the left and searching for "HTML5".

Html5projecttemplate

Make a note of your project location so we can use the Git Bash shell to push our source.

Step 3: Push it to AppHarbor with Git

Once you've got your project all set up and ready to deploy, navigate to your project's location, right click on the root directory and select "Git Bash Here".
Enter the following commands to initialize your new Git Repository


  1. git init
  2. git add .
  3. git commit -m "initial check in"

Once you have your files committed locally, you are ready to push up to the AppHarbor Git Repository Url.

Here are examples of the commands to do that:


  1. git remote add appharbor [YourSiteRepositoryUrl]
  2. git push appharbor master

Gitbashhere

GitinitappGitpushapp


Enjoy Your Site

Congratulations, you've just deployed your first HTML5 website.

Now all you have to do is navigate to your app's url; i.e http://best-site-evar.apphb.com.  

Next step, add a database and add the code first entity framework NuGet package for fast database scaffolding.  Hopefully I'll get a tutorial up for that soon.


Monday, March 7, 2011

DataGrid Column Header Binding Behavior

I ran into a problem binding a localized string to a Silverlight 4 DataGrid Column Header, it turns out the Header property on a DataGridTextColumn isn't a dependency property and so it doesn't support binding.  This behavior will let you bind a value to the header.


Hope that helps someone else out who may be trying to localize their application.

Jacob