Master WPF on your iPhone

February 16, 2012

After being obsessed with WPF for so many years, I can’t just forget about it. Even though my focus is now on iOS development, I still think that WPF is an awesome platform. That’s why I wrote an iPhone app named Master WPF. It contains 500 questions, spread across 28 topics, that I painstakingly wrote, organized, and proofread until my eyes bled. The questions will help any WPF developer sharpen their skills.

It’s for WPF noobs, gurus, and everyone in between.

Master WPF on your iPhone or iPod Touch

Master WPF on your iPhone or iPod Touch

You can download Master WPF for free on your iPhone or iPod Touch, running iOS 5 or greater. The app comes with 15 free questions so that you can try it out. If you decide that you want to master WPF with my app, you can make a small in-app purchase to unlock all 500 questions.

Think of it as a donation to a recovering WPF addict.

Screenshots of Master WPF

Screenshots of Master WPF

For more info about Master WPF, please check out

End of PDC 2008

October 31, 2008

I just got back to NYC after spending six days in Los Angeles, attending the PDC.  It was my first time attending a conference of such massive proportions.  If you have never attended one, I suggest you do.  Aside from the exciting material covered by some (certainly not all) of the sessions, it also provides you with a great way to meet people and make professional contacts.  Also, you end up leaving with a veritable mountain of crap…err “swag”…that you can eventually throw away after you lug it all home.

I was blown away by how much interest and enthusiasm I saw for WPF.  Most of the WPF sessions (i.e. presentations about WPF) were packed, and even had overflow rooms that were packed.  I think a lot of people are starting to see WPF as the future of desktop Windows programming, not as just some interesting “thing” that Microsoft is promoting.  The session about the new WPF DataGrid and Ribbon controls had two overflow rooms!

I’d like to thank Infragistics, my employer, for sending me out there.  I’d also like to thank the great people I met out there, who made the experience so enjoyable and interesting.  It was great to finally meet many of the WPF Disciples, and other folks, with whom I had only ever communicated via e-mail in the past.

Yield to the power of yield

May 26, 2008

I must admit, I had never really become too comfortable with the C# ‘yield’ keyword until recently. I knew that it was introduced in C# 2.0 as a means of simplifying the creation of an enumerator. I also knew that the C# compiler interprets the code in a method that uses the yield keyword. A compiler-generated implementation of IEnumerator exists behind the scenes, which implements the logic to produce the enumerator you declared in C#. Beyond that vague understanding, I was not too familiar with it. It felt “odd” so I rarely used it.

In my ‘Simplifying the WPF TreeView by Using the ViewModel Pattern‘ article I have a demo program that lets the user search through the items in a TreeView. The search logic uses the yield keyword, as seen below:

(Click on the image to view the source code at full-size)

The article also has a demo program that lazy-loads each item’s children. That demo does not provide the ability to search. Shortly after publishing the article, two people asked how to have a lazy-loaded tree with search capabilities. Aside from the fact that performing a search that produces no matching items will force all of the items to be loaded; it is a reasonable question. I decided to implement a solution.

At the time, I misunderstood exactly how my search method used the ‘yield’ keyword. I was under the false assumption that it was executing the search logic to completion when the FindMatches method is called, and storing the results in a collection of some type. As we will see later, this is entirely untrue, but I, too, can be an idiot sometimes. :)

I took the load-on-demand sample and added in the ability to search the items. The UI looks like this:

Based on my misunderstanding of how a yield-based enumerator works, I thought it would have been bad to use it in this situation. Since I (incorrectly) thought that it walked down the entire data tree upon creation, performing a search with it would have forced the entire tree to be loaded into memory at once. So I thought that I had to create a custom search algorithm that would perform the search and only load as many items into memory as necessary to find the first matching item. After finding the first match, the next time I perform the search, it should only load as many items as necessary to find the next matching item. And so on, and so on…

I have plenty of experience building recursive algorithms that walk over trees, but I had never built one like this. Most recursive algorithms store their state on the callstack. Each time the recursive method is called, a new frame is pushed onto the callstack, and it keeps track of the local variable values for you. By ‘local variables’ I mean things like, the current item, the index of a for loop, the parent item to which we return after processing a sub-tree, etc.

That’s all well and good, until you need to create a recursive method that returns a value and, later on, needs to resume processing from where it left off last time it was invoked. This is exactly what I needed to build. I needed to create a recursive algorithm that stores its state in an external data structure, so that I can effectively save and load that state between executions. It was an exciting Sunday morning programming exercise, for sure!

The source code of the demo app is available at the bottom of this post. In it, you’ll find a TreeViewItemViewModelSearch.cs file. It contains all of the code involved with this implementation. That file contains a static class, TreeViewItemViewModelSearch, which contains just one public method:

The SearchResult class implements IEnumerable<TreeViewItemViewModel> and its GetEnumerator returns an instance of SearchEnumerator, which implements IEnumerator<TreeViewItemViewModel>. This search logic is invoked by the enumerator’s MoveNext method:

(Click on the image to view the source code at full size.)

The helper classes seen in that algorithm are listed below:

As it turns out, none of this is necessary at all! If you look in the TreeViewItemViewModel class, you will see how there are two implementations of the search functionality. One of them uses the very elaborate code we just saw, and the other, which works JUST AS WELL as my code, is a simple method with the ‘yield’ keyword. Click on the following image to see how both techniques are used:

As seen in the FindMatches_Yield method, all that I had to do was add in code that lazy-loads the child items before it searches them! The compiler-generated implementation of my search logic will be invoked every time the enumerator’s MoveNext is called, and it only searches for one item at a time. This is perfect for a load-on-demand scenario. If I had known about this earlier, I never would have bothered to write that custom search enumerator. But then again, it was a lot of fun and quite interesting to implement, so it’s all good!

Download the source code here: treeview_with_viewmodel_lazyload_and_search_demo Be sure to change the file extension from .DOC to .ZIP and then decompress the file.

IdentityMine Sweetens the Pot

May 7, 2008

The Podder Skinning Competition is really starting to heat up now!  IdentityMine is now giving away their awesome blendables product as a prize to the winners.  The list of prizes has grown quite a bit since the competition first began, and this latest addition definitely cranks it up a notch.  Thanks a lot, IdentityMine! 8)

I have already received a few e-mails and comments from people who are creating a Podder skin for the competition.  I can’t wait to see what they come up with.  Also, Karl told me that he is locked onto winning the steak dinner at Smith & Wollensky prize like a heat-seeking missile.  :)

Watch my presentation at the WPF Bootcamp 2008

March 29, 2008

A few months ago I flew out to Redmond so that I could speak at Microsoft’s WPF Bootcamp.  I gave a presentation about implementing the Model-View-Whatever pattern in WPF, which was received very well by the attendees.  After giving that presentation I solidified the material into my ‘Using MVC to Unit Test WPF Applications‘ article on CodeProject.  This seminal work is the foundation of the structural skinning architecture seen in Podder.

The entire WPF Bootcamp 2008 was videotaped and recently published online.  Karsten announced it a few days ago in this post.  All of the videos and associated downloads are hosted in a Silverlight application (of course), which you can view hereNOTE: That page comes up empty for me in FireFox, so be sure to open in it Internet Explorer.

You can find my presentation under Day 3.  It is called “Hello, Real World!” and runs for about one hour.  I highly suggest you check out some of the other presentations, too.  There were many interesting things discussed during the bootcamp.

In case you want to download the entire video file,which is quite large, you can grab them individually from this page.  My video is around 330MB so it might take a while to download it, but if you’re just dying to fill up that new external hard drive…  :)

Craig Shoemaker unveils Pixel8

March 4, 2008

Ever since I rejoined Infragistics, I have been in almost daily contact with Craig Shoemaker. We do not work in the same group, or even work on the same projects, but I just really enjoy chatting with him since he’s an all-around great guy. In case you are not already familiar with Polymorphic Podcast, Craig’s popular .NET podcast, I recommend you check it out sometime.

Today Craig announced his new podcast, Pixel8. This new podcast, produced by Infragistics, is all about user experience. I am very excited about this because I think user experience is a very important aspect of any successful user-facing application. You can learn more about Pixel8 via this brief introductory video:

Buying themes for WPF applications

February 19, 2008

The Web is full of comments where people generally voice the same issue with WPF. It seems that everyone and their grandmother thinks WPF is only useful for companies building apps with “differentiated user interfaces.” Ya know, Times Reader, Yahoo Messenger for Vista, etc. A common thread is that if you are building line-of-business (LOB) applications, WPF is not going to give you much over WinForms. While understandable, this opinion is simply wrong. Need proof? Check out the Lawson Smart Client app.

With that said, there is a point to take away from the general consensus. I totally agree that you are missing out on a lot of WPF’s potential if you do not have Visual Designers around to Blend up some fantastic user interfaces for you. Even if you have the budget to hire Visual Designers, it’s not exactly a simple task to find someone who has strong VD skills, as well as a firm background in software development. Those people are in high demand, and are in low supply (‘low’ compared to, say, competent WPF developers…oh wait…nevermind). ;)

What I expect to see, in abundance, is third-party and open-source visual themes that can simply be plugged into any application. Development teams will use pre-canned visual designs. There’s gold in them hills. Once a development team can purchase/download a set of styles/templates/resources to turn their drab LOB apps into something like Lawson Smart Client, WPF will be the de facto choice for LOB projects. Of course, I assume by that time design-time support for WPF will be much better and supportive of RAD. Without that, all bets are off.

These types of pre-canned themes are already available to a certain extent. The Reuxables product seems interesting. I have not used it yet, but it seems on the right track and worth trying out. Infragistics offers Theme Packs, which you can use to restyle Infragistics controls. Products like these are the future of WPF and Silverlight development, considering that most dev teams neither have access to or can find Visual Designers.

WPF vs. ASP.NET – An Architect’s Perspective

December 20, 2007

Karl Shifflett recently published a fabulous blog post explaining why he decided to use WPF instead of ASP.NET for his company’s large software product.  It is very down to earth and unbiased.  He obviously put a lot of thought into this, so I highly recommend checking it out.  Here’s the link:

The .NET world is now a better place

December 14, 2007

When I worked in the Infragistics WinForms development lab, I had the privilege of working with Andrew Smith.  If such a thing as a “guru” exists, Andrew is it.  His mastery of .NET programming is the best I have ever seen.  I don’t give compliments of that magnitude too often, but he deserves it.  Heck, as soon as he got involved with the Mole project, some of the really nasty bugs immediately disappeared and the performance improved drastically.  Abra-ca-dabra!

Fortunately, he has decided to share some of his programming thoughts with the rest of the world.  Yahoo!!  He recently started a blog here:

Thanks Andrew!

Meet my alter ego

December 13, 2007

This post is for my loyal readers out there.  In case you are looking for some extra blog posts by Yours Truly, you’re in luck.  Now that I work at Infragistics, I have a blog on their blog site as well.  My new blog is not devoted to WPF, in fact, I intend on posting all of my WPF content here.  The new blog will contain the type of posts that I never felt I should write about on a blog called “Josh Smith on WPF”.  

My new blog will be about all of the cool technologies that I research and use for my new job.  It should be a lot of fun, so why not stop on by once in a while to see what the non-WPF Josh is thinking about?  If you want to check it out, here are the links:


RSS 2.0:


See you there!


Get every new post delivered to your Inbox.

Join 273 other followers