Last week I had another incredible time at Microsoft’s annual Build conference. This year was particularly exciting for me, as I was invited to speak about some real-world experience on Building Apps for both Windows and Windows Phone. This talk is all about cutting to the chase: cross-platform development is challenging. It's also increasingly a reality we must accept, embrace, and learn to take advantage of. By demonstrating a "real-world" app designed for Windows and Windows Phone, you will learn six battle-tested techniques for maximizing both code and skill reuse between multiple platforms. Get the code If you enjoyed the talk and would like to check out the code for the Real-world Stocks apps that were built on stage, use the following Github link: https://github.com/matthidinger/Build2013RealWorldStocks Introspective This was my first talk at a major...

Xamarin is all the rage in mobile development right now. They just threw an amazing conference in Austin and started trending on Twitter during the opening keynote.
But I’ve identified myself as a Microsoft platform dev for years now, and Xamarin is all about iOS and Android. Why am I, and more importantly Microsoft, seemingly so interested in this product?
Xamarin
If you haven’t been following along, Xamarin is a company that is now 22 months old, founded by Miguel de Icaza and Nat Friedman. Their product allows you to develop native iOS and Android apps using the most wonderful language of all time: C#.
Their toolset, among other things, lets you use Visual Studio to build these apps, offering rich designer experiences, and even let you compile iOS apps using Windows thanks to some neat remoting technology.
Evolve Conference
Last week they threw their very first conference, and it was a truly impressive feat. A...

I recently had the opportunity to speak at Microsoft’s New Era of Work conference in Chicago. Below you’ll find the presentation material, the Real-World Stocks project which demonstrates the principles, and a high-level recap of the lessons learned while practicing the following techniques in actual apps. Slides A number of slides were provided by Microsoft, and many specifically from Matthias Shapiro. Be sure to check out his blog for more excellent Windows Phone articles! source For this talk I started with my Real-World...

On a recent project I needed to extract the windows phone user-agent string for our usage analytics, and it had to be the same user-agent as the IE requests. While this didn’t end up being as straight forward and I had hoped, the code below involves a few simple steps. First we have to insert a collapsed browser onto the page, then we can navigate it to specifically crafted HTML/JavaScript, which will in-turn notify the WebBrowser control of it’s user-agent. All you need to do is store it somewhere; in my case, I put it into a custom ApplicationSettings class, but you can store it anywhere you want. Usage Since this code requires adding a WebBrowser control to a page, it’s probably easier to do in code-behind as opposed to a view model. public partial class HomeView : PhoneApplicationPage
{
public HomeView()
...

I’m currently wrapping up a Windows Phone project and thought this would be a good time to share some of the more reusable stuff we needed. Zebra-striping alternate rows This particular app displays a lot of tabular data, so we wanted to zebra-stripe the rows to make them easier to discern. At first we tried using a ValueConverter to get the index of the current container, but this method didn’t end up working with the Telerik DataBoundListBox. Instead, we wrote a simple IndexingObservableCollection that will automatically populate the Index of each item as it’s added to the collection. This method also works with the infinite scrolling feature of Telerik’s listbox – which we actually needed anyway. IndexingObservableCollection To use it, you have to implement the IIndexable interface which ensure an Index property on your model. Then simply replace the ObservableCollection property on your view-model with the following IndexingObservableCollection.public class...

This blog is quiet… too quiet. It’s been a busy couple of months since starting at Clarity in January. PowerPoint, for better or worse, became my after-hours IDE. Below you will find some of the recent talks accompanied by their slides and code. Hopefully I didn’t forget anything, but please shoot me a comment if I did! WindyCityGo Apr 5 – 6, 2012 WindyCityGo is a two-day conference in Chicago that covers all things mobile. This year they added Windows Phone to their lineup and I was invited to speak on “Real World Windows Phone Development.” My talk covered an intro to metro and supports my tutorial series on building a polished Stocks app for windows phone. And now that my speaking gigs are winding down I can finally get back to that series! GET THE CODE ...

If you drink from the fire hose read Ayende’s blog you would notice a lot of Anti-Repository talk over the past couple years – which I fully agree with. Back in 2009 he declared repository is the new singleton, stating: My current approach for data access now is: When using a database, use NHibernate’s ISession directly Encapsulate complex queries into query objects that construct an ICriteria query that I can get and manipulate further When using something other than a database, create a DAO for that, respecting the underlying storage implementation Don’t try to protect developers Naturally he gets a slew of comments asking how he handles certain scenarios without using the repository...

By using the the simple SelectorAttribute and EditorTemplate described in this post, you will get rich support the following very common scenarios (and flip between the various modes with ease): Single selection from a Drop Down Single selection from Radio Buttons Multiple selection from Check Boxes Multiple selection from a List Box Read-only mode combines multiple values into a comma-delimited string The Canonical example Say you’re inserting a new Product and need to set the CategoryId property. You make a simple input Model wanting to use EditorFor, but CategoryId gets rendered as a useless textbox. The challenge is: Retrieving the list of categories to present to the user Keeping the selected item(s) in sync with the...

Many ASP.NET applications utilize the System.Web.Caching.Cache in some way. While it offers a pretty simple Dictionary-like API that your app can start using immediately, I typically create a combined “tell-don’t-ask” wrapper around it – which has some additional architectural benefits as well. Out of the box concerns A very common usage of the Cache API can be seen below, but there are a few initial problems I have with it: Ugly, non-generic casting Manual null checks Duplicating the string for the key Lots of implementation details sprinkled around No out of box way to scope the cache. For example, cache a unique copy of the item for each User public ActionResult Bad()
{
var firstVisit = HttpContext.Cache.Get("FirstVisit") as DateTime?;
...

Many line-of-business applications contain dozens of forms similar to the following, each field consisting of a few common characteristics: A Label with the name of the field The field editor itself Asterisks and special styling for required fields A tooltip that can be hovered for a detailed description of the field Validation messages if the input is incorrect To achieve this, we can create the following Model public class ProductInput
{
[HiddenInput(DisplayValue = false)]
public int Id { get; set; }
[Required]
public string Name { get; set; }
[Required]
[Display(Description = "A brief description of the product")]
[DataType(DataType.MultilineText)]
public string...

The title is slightly tongue-in-cheek, but I do believe selling is a crucial aspect of being an ‘architect.’ And I don’t mean selling to customers. But first, a backstory A long time ago, at a client far, far away… they were making a big push to SOA. My project at the time was calling a few methods from a referenced assembly, but the client’s architect said I must re-write it using their new WCF endpoint instead. I had my reservations about this change because the services so far were not known to be stable nor discoverable. Now I am certainly no expert at applying SOA, but I do appreciate that it consists of more than simply exposing everything through web services. In my mind, before even attempting to impose an SOA mandate across an enterprise you must establish some baseline infrastructure: A...

This past weekend I decided to upgrade my Subtext blog to VS 2010 so I could finally rid my machine of VS 2008. After some small hiccups it was ready to rock, and thankfully the deployment to my server was entirely painless with WebDeploy. So being in VS 2010 and having fully tested my deployment process it seemed like a good time to make a tweak to my Skin that I’ve been wanting to try for a while: showing “Hero Shots” next to each post. Hero shots? I’m not really sure what they should be called, I just know I’ve heard the term hero shot a lot this year and it seemed to fit, but call it whatever you want The idea is pretty simple: when viewing a list of posts (the home page, a specific tag, the archives) I want to show an...

DoddleReport generates tabular reports from any IEnumerable datasource. Out of the box it can render reports to Excel, PDF, HTML, and CSV – fully pluggable of course. I created the project to provide reporting output over the LINQ queries we had already written for an application, but maybe you can find other uses for it. So what does it generate? The following samples are generated live in real-time (notice the data will change every time you open the report) Excel Report (OpenXML) Creates a native Excel file using OpenXML ...

Series Introduction and Outline This series is going to walk through building a polished, functioning Windows Phone app from start to finish. The app is called Realworld Stocks and the full source code will be available on CodePlex as the series progresses. I’ll be using Mercurial to encourage forking and maybe even pull requests from developers who want to contribute their own real-world solutions. View the Series Introduction and Outline Navigation Basics Even though this series assumes a basic understanding of Windows Phone development I want to briefly touch on the basics of page navigation. Windows Phone apps follow a basic stateless navigation paradigm very similar to that of a web app. Each page in the app is represented by a URL ending with .xaml. How to Navigate to a new Page (the bad way) ...

As Phil put it recently: it’s not every day you write this sort of blog post. A few people have been asking me why there haven’t been any updates on RealWorldWPDev in the last few weeks, and the simple answer is that I was pretty swamped over a particular life decision: changing jobs. They say changing jobs is one of the most stressful things we do in life, and I definitely believe it. November 30th marked my last day at Triton-Tek after 4.5 years. It was by far the best job I’ve had to date. I got to work with some really great people, on some awesome projects, and made good friends along the way. It was a really tough decision to leave. What’s Next? But Chicago is a big city with some great companies and great talent. I would be remiss if I didn’t...

This post is an update to my original ASP.NET MVC Recursive TreeView Helper from almost 3 years ago. Oddly enough it’s still a high-traffic post and has close to 50 comments asking for an update or a complete solution to download. I figured if I was going to do that, I might as well give the API a much-needed facelift and pop it on NuGet. What is it? Given the following self-referencing hierarchal model… public class TreeViewLocation
{
public TreeViewLocation()
{
ChildLocations = new HashSet<TreeViewLocation>();
}
public int Id { get; set; }
public string Name { get; set; }
public virtual int? ParentLocationId { get; set; }
public virtual ICollection<TreeViewLocation> ChildLocations...

Series Introduction and Outline This series is going to walk through building a polished, functioning Windows Phone app from start to finish. The app is called Realworld Stocks and the full source code will be available on CodePlex as the series progresses. I’ll be using Mercurial to encourage forking and maybe even pull requests from developers who want to contribute their own real-world solutions. View the Series Introduction and Outline Choices In the Microsoft world we have no shortage of client and server-side HTTP stacks to choose from. Rather than try to cover every possible combination, and to prevent this topic from getting too long-winded, I will keep this part succinct. Our first major decisions revolve around the following options: SOAP or REST? WCF or ASP.NET MVC? Without getting too deep into it,...

Series Introduction and Outline This series is going to walk through building a polished, functioning Windows Phone app from start to finish. The app is called Realworld Stocks and the full source code will be available on CodePlex as the series progresses. I’ll be using Mercurial to encourage forking and maybe even pull requests from developers who want to contribute their own real-world solutions. View the Series Introduction and Outline The windows phone panorama Many apps lend themselves nicely to a Windows Phone Panorama. CTA Watch looks similar but it’s actually a Pivot with a background image. After going back and forth for a bit with Real-world Stocks I decided that the panorama looked pretty nice and went with it. Thanks again @Templarian for the background! Be sure to hit...

Series Introduction and Outline This series is going to walk through building a polished, functioning Windows Phone app from start to finish. The app is called Realworld Stocks and the full source code will be available on CodePlex as the series progresses. I’ll be using Mercurial to encourage forking and maybe even pull requests from developers who want to contribute their own real-world solutions. View the Series Introduction and Outline Caliburn.Micro Many Windows Phone Applications use a lightweight MVVM framework for basic infrastructure services. Realworld Stocks is going to use Caliburn.Micro. I have had great success with Caliburn.Micro in my previous Windows Phone and Silverlight apps. CM was created by Rob Eisenberg and is under active development and has a great community and following. This article is going to walk through a lot of Caliburn.Micro setup, but...

Series Introduction and Outline This series is going to walk through building a polished, functioning Windows Phone app from start to finish. The app is called Realworld Stocks and the full source code will be available on CodePlex as the series progresses. I’ll be using Mercurial to encourage forking and maybe even pull requests from developers who want to contribute their own real-world solutions. View the Series Introduction and Outline Before you begin, install NuGet! NuGet is a Visual Studio extension that makes it easy to install and update open source libraries and tools in Visual Studio. It can be installed directly from within Visual Studio and only takes a minute. In Visual Studio: Tools –> Extension Manager and find NuGet Defining our Solution Structure For our solution we are going...

Series Introduction and Outline This series is going to walk through building a polished, functioning Windows Phone app from start to finish. The app is called Realworld Stocks and the full source code will be available on CodePlex as the series progresses. I’ll be using Mercurial to encourage forking and maybe even pull requests from developers who want to contribute their own real-world solutions. Realworld Stocks The app we are creating is called Realworld Stocks, and this is what it looks like as of today. It’s not much yet, but hey, we’re only a few days in! Hopefully as the series progresses we’ll end up with a pretty nice looking stocks app ready for marketplace submission. Series Outline The following is a rough outline for how I expect this series to progress. Some parts will probably be...

Why? Because I should be able to Get Latest and F5! I think simplicity is a crucial measure of success in all software. I think being able to pull down the source code onto any developer machine and F5 is an important goal to strive for. Removing manual processes and streamlining the development workflow can yield huge productivity gains – especially when onboarding new developers. I believe databases should be provisioned and seeded automatically, all 3rd party libraries should be readily available in the repo, and any manual steps that must be memorized or documented should be avoided at all costs. But this hasn’t been easy on a Windows Phone device The aforementioned goals have been easily achievable in all of my projects except Windows Phone apps. A key component to this workflow is the magical variable known as localhost. When I F5 one...

This morning I received a Microsoft MVP award for Windows Phone Development. I’m really honored to be part of a community that really values knowledge sharing and continuous professional growth such as this. Over the past few years I’ve come to greatly respect and appreciate the vast amount of personal time that many people in the development community (both MVPs and non-MVPs) contribute to help drive our profession forward. I’d also like to offer a very special thanks to the entire Windows Phone Dev community for helping to expand this great platform into the consumer reach that it deserves. There is still a ways to go, but after the impressive world-wide launch of Mango across dozens of countries, carriers, and OEMs on a single day I think we can all agree that Microsoft is taking this seriously. I’m personally really excited to be in on the ground floor this...

The default Model Binder in ASP.NET MVC works fine for most cases. Most of you have probably registered custom binders with it plenty of times. ModelBinders.Binders.Add(typeof(ILoadProvider), new LoadProviderModelBinder());
The issue is that that it’s limited to binding the exact type you add to its dictionary. The ILoadProvider registered above will invoke my LoadProviderModelBinder as long as the controller action parameter is of type ILoadProvider. But what if you have a type that derives from ILoadProvider and still want your custom binding to occur?
Thankfully this is very simple in ASP.NET MVC 3. It comes with a new extensibility point, IModelBinderProvider, and works just like the other providers.
public interface IModelBinderProvider
{
IModelBinder GetBinder(Type modelType);
}
InheritanceAwareModelBinderProvider
With this interface, we are able to create a very simple InheritanceAwareModelBinderProvider.
/// <summary>
/// Adds inheritance support when registering model binders.
/// Any model binders added here will be invoked if the Type being bound inherits...

TechWeek Chicago Starting today and running through next Friday, July 29th is TechWeek Chicago. TechWeek is a week of conference, expo and events with over 2,000 entrepreneurs, business leaders, and innovators, 4 days of conference sessions, over 150 international speakers, 4 days of an expo hall with over 100 exhibitors, 35 competing tech startups, and over 30 independent off-site events. TechWeek connects the newest web and mobile technologies to thousands of Chicago business, academic, community, art, and media professionals- all within one week. For more information about TechWeek, check out http://www.techweek.com. Windows Phone Unleashed During TechWeek Chicago, Microsoft is hosting Windows Phone Unleashed @ TechWeek. This will be an incredible evening getting hands-on with Windows Phone and you will have the opportunity to work with the Windows Phone and Windows Azure experts to help get your app ideas of the ground. More details for this event is...