Enterprise, Touch This

October 4, 2013

Today I’m repurposing my blog to focus on Enterprise LOB and Enterprise LOB touch applications. I’ll be covering WPF desktop applications, WinRT, and Windows Phone 8 applications.

I’m excited about Visual Studio 2013, Windows 8.1, and the Surface Pro 2; looking forward to the next version of Windows Phone 8 operating system as well.

The time has come for the Enterprise to touch their devices.  The touch hardware and software capabilities have advanced a long way in the last two years. Developers can author their touch applications using the WinRT API’s, Windows Phone 8 API’s, HTML5, WPF, or other device/vendor specific API’s.

To all my fellow developers, I do recognize the challenges for putting LOB in WinRT, but I’m choosing to see this as research and development; a time to push boundaries and see where this can go.

I’ll be implementing touch applications at my company; we already have several needs that can be addressed with these types of applications and devices.

Note: I have moved my Visual Studio 2008 and 2010 content pages to the Archive page on the above right. Also, I have left the Table of Contents entries alone so that readers needing Visual Studio 2010 content can still access it.

What to Expect from my Blog (my Roadmap)

I need a scenario to base the initial work on. So I’m going back to the BBQ Shack store and will build the below applications around this fictitious store. This store will have a WPF backend application, WinRT Touch Point of Sale, a Windows Phone 8 Inventory application, and two customer applications for placing orders using a Windows Phone 8 or Windows 8.1.

I’ll start off by compiling Prism 4 against .NET 4.51 and Unity 3.0. I use Prism in all my WPF applications.  I’ll be using Unity 3.0 in all my other applications.

Next, Ocean 4 for .NET 4.51. This is a very seasoned version that has been in production for over 2 years.  Many new API’s and helpful framework classes.

Next, Crank for .NET 4.51.  Crank is a code generator that uses metadata and T4 to generate entities, stored procedures, forms, and much more.  Crank is like having scaffolding on steroids, where the T4 templates can consume very detailed metadata and inject this into your code. Crank can generate code for any platform and has pluggable T4 templates. I will use Crank for all the below applications.

Next, BBQ Shack, a WPF/Prism/SQL Express 2008 R2 application that targets .NET 4.51.  All of the below applications will consume the data from the BBQ Shack SQL database.

Next, Ocean 4 for WinRT.

Next, WinRT LOB Touch Point of Sale (POS) for the BBQ Shack cash register.  This should be fun, using my Surface 2 Pro as a cash register.

I’m toying with the idea to write BBQ Shack as a WinRT app as well as the above WPF app. This will really be fun and challenging.

Next, WinRT Customer Application for order from the BBQ Shack.

Next, Ocean 4 for Windows Phone 8.

Next, Windows Phone 8 LOB Inventory taking application.  Barcode scanning, inventory verification, etc. Phones are so powerful these days, why not get the most value from the device, put it to work.

Next, Windows Phone 8 Customer Application for ordering from the BBQ Shack.

Then I’m going on a cruise and will probably need therapy!


This will be a wild ride over these next months. I will take time to write blog posts that explain the API’s and tools. It feels good to get back to blogging and speaking at User Groups and Code Camps.

Have a great day,

Just a grain of sand on the worlds beaches.

Code for Boise Code Camp 3-16-2013

March 15, 2013

Data Caching Session

This example application is for the session, “An Approach to Real World Application Data Caching” can be downloaded below. Included in the download is the demo application, the Ocean 3 framework binaries, and the  PowerPoint deck.

This application demonstrates one solution to real world data caching.  I use the techniques presented here in production applications with many users.

In the future, I’ll write a full blog post on this and possibly post a video walkthrough. I’ll also post the Ocean 3 code, just have not had time to document and write a full example application.

Mole Session

A pdf of the Mole slides can be downloaded below.

Mole can be purchased or a demo of Mole can be downloaded at Molosoft.com.


After downloading change the extension from .zip.DOC to .zip. This is a requirement of WordPress. You will also need to Unblock the file using the file properties dialog in Windows Explorer.

Download (Data Caching Demo w/Database (1.4 MB))

There is a database backup in the \DataCachingDemo\Database Backup folder.  You’ll need to restore this to a SQL Server 2008 R2 or SQL Server 2008 R2 Express. If you restore to SQL Server, you’ll need to change the connection string to point to your server.  Currently, the demo application points to SQL Server Express.

Download (Mole Session Slides in PDF (613 KB))

Have a great day,

Just a grain of sand on the worlds beaches.

Speaking at Boise Code Camp March 16, 2013

February 25, 2013

I’m very much looking forward to the 16 March, 2013 Boise Code Camp. Speakers have signed up for some very cool and informative talks.

I’ve signed up for two sessions myself. The abstracts can be viewed here.

  • An Approach to Real World Application Data Caching
  • Using Mole for Debugging Visual Studio 2010 and 2012 Applications

In addition, I’ll release Ocean 3 as part of the associated session source code.

Have a great day,

Just a grain of sand on the worlds beaches.

Boise Code Camp Prism, Ocean 3 Session

March 24, 2012

The links to the code presented at the Boise Code Camp is in the below Downloads section.

This links include Ocean 3 and a modified Prism 4 library that has two new features.

The Ocean 3 solution includes a Prism Ocean Demo application that shows off Ocean working with Prism. In a later release, I’ll add database demonstration code as well that uses the new and improved Service<T> and Repository<T>.

The demo application shows off:

  • WPF Ribbon being populated by a Prism Region; when forms are navigated to, their respective ribbon tabs are automatically rendered.
  • Automatic view/view model wiring up by the Unity container. No view or view model navigation registrations required.
  • Automatic setting of the correct IRegionManager on all view models; this region adapter does not draw the IRegionManager out of the IoC container, instead it uses the one assigned to the view. This technique prevents the incorrect IRegionManager being assigned in cases of child windows or scoped regions.
  • Demonstration of a child window hosting a form; that same form can be shown within the shell or child window requiring no form or view model modifications to function correctly; i.e. no “if in popup then do this code.”
  • When views are navigated away from, the currently focused control is cached; when that same instance of that form is navigated back to, focus will automatically be set to the correct control.
  • Queued dialog service for forms.
  • The view modal dialogs are asynchronous, by not blocking the UI thread, a form that has a dialog displayed, can be navigated away from and navigated back to.
  • When a view has a view modal dialog displayed, the views ribbon tabs are automatically disabled.
  • Ocean FormControl that provides many services for LOB forms.
  • Ocean FormNotificationControl that shows the form status from a validation perspective.
  • Ocean provides a comprehensive validation stack.
  • In addition, many small features are also shown.

I’ll release a new version of BBQShack soon, PrismBBQShack. This is a complete end-to-end store application that will show off all features of Ocean 3 (like the data stack) and will have a Win8, WinRT XAML touch-enabled point of sale application.


After downloading, you MUST read the READ ME NOW.txt file in the Acme.Example solution.

After downloading, you must rename the to downloads from .zip.doc to .zip.  This is a requirement of Word Press.

Ocean 3

Modified Prism 4

To use the modified Prism 4 download, after unzipping, go to the \Prism\Prism4\ folder and run these two batch files:

  • Run Update Prism Binaries.bat
  • RegisterPrismBinaries.bat

They will rebuild the supplied modified Prism 4 and will register this version of Prism in the registry so that you can use the Add References dialog. This modified version of Prism will work with any current Prism application as no API’s were removed or changed, only added.

Have a great day,

Just a grain of sand on the worlds beaches.

Boise Prism, Unity, WPF, MVVM Code and Decks

June 29, 2011

Everyone had a great time in Boise this week with developers from the United Kingdom and all over the United States.  WPF is alive and well and being used in corporate development along with Prism!


C# early version of Ocean.

  • Data Binding
  • M-V-VM
  • Commands in M-V-VM
  • Dialogs in M-V-VM
  • Data Validation
  • M-V-VM Tips & Tricks
  • Unit Testing & Moq
  • Introduction to Prism
  • Unity and Dependency Injection
  • Shell and Bootstrapping
  • Modules
  • Regions
  • Events
  • Navigation


The download includes PowerPoint decks for most of the sessions and source for all sessions.  Also included is an  Extras folder with goodies.


You can download the code and decks from my Sky Drive here.

Have a great day,

Just a grain of sand on the worlds beaches.

Karl’ Roadmap Nov – Dec 2010

October 31, 2010

While my blog has been a little on the quiet side, I’ve been going like a rabbit with his tail on fire.  Metaphorically speaking, “What lies beneath the water line of the iceberg is about to be unveiled.”

I’ve been getting emails, Tweets, and blog comments asking me about XAML Power Toys, Ocean, Mole 2010, my upcoming cruise, Prism, In the Box, patterns & practices 2010 Symposium code; so I thought a short roadmap post is in order.

Prism 4

Prism 4 will RTW either this Thursday, 4 November 2010 or early the following week.

The patterns & practices Prism team has invested a lot of resources in the Prism Library and written guidance.  The documentation has been completely rewritten with new topics added such as MVVM, MEF and navigation.

Once released, I’ll blog regularly on the features and content of the Prism guidance.  Additionally, I’m researching the possibility of conducting three Prism events; I’m thinking of using the two day event model, holding the sessions over a Friday and Saturday.  Once the dates and locations are firmed up, I’ll provide plenty of lead time to plan and register.

patterns & practices 2010 Symposium Code

On the day Prism v4 ships, I’ll post the MVVM Training that was package using In the Box.  In the Box is explained below.

This Friday, 5 November 2010 I’ll publish a blog post and video covering the Prism Region Navigation sample application that also demonstrated the Task Parallel Library Futures pattern that streamlines view model code.

XAML Power Toys

I was hoping to get to the next release in November but am putting this work off until early December.  I’ll release a new version with the suggestions and performance fix on 19 December 2010.  If you have a suggestion or requested fix, please leave a comment here.

Mole 2010

Team Mole has put in several hundred hours in this new release.  We have been cautious with our release, wanting to provide the very best product.  Mole 2010 is code complete, has a great new UI and many new features you’ll love.  Team Mole is completing the documentation and videos and hopes to ship very soon.

You can follow Josh Smith’s blog and my blog for the release announcement.

We can also be followed on Twitter:


I’ve already ported Ocean to C#, Windows Phone 7 and released it here.

I’m currently porting Ocean for WPF and Silverlight to C#.

While on my cruise over Thanksgiving, I’ll write a reference implementation that shows Ocean v3 in action.

Expect this to be released on Sunday, 5 December 2010.

Mexican Riviera Cruise

It has been a year and the time has come to set sail again; this time to the Mexican Riviera.  With three full days at sea and each night spent at sea, kdawg will have plenty of coding time!  No email, no phone, no Internet, just heads down coding.  The sounds and scent of the ocean breeze; gentle rolls of the ship and room service grill cheese, sets the stage for a week of creativity and productivity.

I’ve been wanting to update my Stuff application to consume Amazon.com data and to support many more item types.

The core scenario is to be able to look up movies, books, games, music and software I currently own using a phone.  This would allow me to see what I own, if I don’t have it, quickly check the price at Amazon.com and either purchase it at the store (automatically adding to my database) or put the item in my Amazon.com shopping cart.

To accomplish this, I’ll be taking these three patterns & practices assets out for a test drive, Prism, Windows Phone 7 Developer Guidance, and Unity Application Block.  To those, I’ll add Ocean v3 to the supporting cast.

The application will have an oData cloud services component with WPF, Silverlight, Windows Phone 7 and ASP.NET MVC3 front ends.  The cloud services component will be hosted on my Discount ASP.NET site.  Each developer wanting to have their own live service, will need to deploy the backend to their own hosted web server.

Developers will be able to compile and run the application locally on their system.  For Amazon.com access you’ll need a free developer account.  Again, to use the application remotely, you’ll need to host the cloud component on your web server.

What is exciting to me is the notion of a single cloud service consumed by the very cool UI stacks offered by Microsoft .NET.

It will a lot of fun working with the technologies that are new to me, Windows Phone 7 and ASP.NET MVC3.  When coding, I’ll be looking for code-reuse opportunities when writing the WPF and Silverlight applications powered by the above patterns & practices assets.  All-in-all, a very relaxing and fun vacation.

Just so you don’t think I’m insane and never stray from my keyboard, I’ve signed up for a 7 hour dolphin training experience and a day on the jet ski during my cruise.

The 7 hours with Flipper is one of those bucket list goals I can finally check off and is the main reason for visiting the Mexican Riviera.  The day on the jet ski will be one big nasty adrenalin rush.  The other day in port will be spent shopping for some cool shirts, a sombrero and tasting the local cuisine.

Expect this application to be released on Sunday, 5 December 2010.

In the Box


At the patterns  & practices 2010 Symposium and at the post PDC 2010 Windows Phone 7 Lab Day, I previewed, “In the Box” and the first training package, MVVM Training.

So far response to this format and the content has been very favorable.

The training is unique because it’s consumed within Visual Studio 2010.  The interface is pictured below.

To create the content, I followed the training videos presented on Channel9 here.  For more information you can also follow Michael Lehman’s blog.

This will ship from the Visual Studio Code Gallery on the same day Prism v4 ships, either Thursday, 4 Nov or the following week.  My next planned training package for In the Box will be Prism v4.  Remember, every thing comes “In the Box.”


Click the image to view full size

Date Summary

Check my blog or follow me on Twitter for these announcements:

  • 4 Nov – Prism v4 (could possibly ship the following week)
  • 4 Nov – In the Box (could possibly ship the following week)
  • 5 Nov – Prism Region Navigation with Task Parallel Library Futures example  (could possibly ship the following week)
  • 5 Dec – Ocean v3, and the vastly upgrade Stuff application with multiple UI front ends
  • 19 Dec – XAML Power Toys update


WOW – what a way to close down 2010!  Looking to power down after the 19th of December; then crank back up January 2011.

Have a great day,

Just a grain of sand on the worlds beaches.

Windows Phone 7 – Application Lifecycle – Ocean for the Phone

October 17, 2010


On October 9th 2010 I did a presentation at the Silicon Valley Code Camp on the Application Lifecycle for Windows Phone 7.  This last week was KA-ray-zeee busy at work and I didn’t want to just post the slides and code I had at code camp.  Better to wait and really do a good job, so here it is.


First, I would like to acknowledge the outstanding decks and examples that the Microsoft Windows Phone 7 Evangelism Team has been and continues to publish.  Team members I’ve been working with are Yochay Kiriaty and Jaime Rodriguez.

I created the provided deck from several decks published by the Evangelism Team.  I edited and added content for the session I did.

For the three example applications, I studied the Evangelism Team’s material, samples on the web, added many hours of learning and ported Ocean to the Windows Phone 7.

This was a lot of fun, in-fact more pure fun than I’ve had in a while.  Don’t get my wrong, I love what I do everyday and the opportunities I’ve been blessed with at Microsoft.  Maybe because the phone is new, I didn’t really know much about it, but was able to understand it and get productive quickly.  Additionally, the Visual Studio 2010 tooling worked great. 

No other way to say it, “developing on Windows Phone 7 is a lot of fun.”  Very much looking forward to getting my own device.

I’m encouraged that Microsoft has a commitment to the XAML language and that I was able to leverage my huge investment in WPF with Silverlight 3-4, and now the Windows Phone 7.  The ability to transfer my investment across platforms and devices is a fantastic benefit to developers on Microsoft’s stacks.

Let me now turn our attention to what is in the box (the download).

Presentation Slide Deck

The deck is in the solution folder and explains each topic clearly.  The application lifecycle concepts are repeated several times in different ways so the reader can grasp tombstonning.

The code snippets in the deck come from TravelReporting project and the OceanFramework.Phone project.

ApplicationLifeCycle Project

The purpose of this application is to provide a nice clear log of the application’s constructors, methods and events as they execute.  It is critical to your success that you learn the phone’s application lifecycle.  This program can help with that.

Crack the App.xaml open and look at the CustomHyperlinkButtonStyle.  I use this to make a Hyperlink control look and act like a Button.  I do this so that I can navigate from XAML and not have to wire up a command or click event handler.  You’ll see this style used in all three applications where appropriate.

Notice how clean my debug output window is.  That’s because I’ve turned off the other messages.  To turn off the other messages, right click the debug output window while debugging.  Then unselect messages on the context menu that you do not want to see.  Below, I just want to see my phone messages, so I’ve left Program Output selected.



Creating the log messages is very simple, just call Logger.Log();  You can also pass an optional notes string.

void Application_Launching(Object sender, LaunchingEventArgs e) {

The magic is in the below Log method.  By creating a StackTrace object, I can extract the calling type and method from the appropriate stack frame.  This type of logging is much better than having to craft each individual log message.  I’ve used this class in each of the projects.

namespace ApplicationLifeCycle.Infrastructure {
    public class Logger {

        public static void Log(String notes = "") {
            StackTrace stackTrace = new StackTrace();

            String typeName = stackTrace.GetFrame(1).GetMethod().DeclaringType.Name;
            String methodName = stackTrace.GetFrame(1).GetMethod().Name;

            if(!String.IsNullOrEmpty(notes)) {
                notes = String.Concat(" - ", notes);
            Debug.WriteLine(String.Format("WP7: {0} - {1}{2}", typeName, methodName, notes));

        private Logger() {

LaunchersAndChoosers Project

This project demonstrates 3 launchers and 3 choosers.  It also provides a lot of logging so that you can see what goes on and when.  Spend some time, using the application.  Then predict the sequence of events before executing them, you’ll have the application lifecycle down quickly.

Take a look at the MainPage.xaml and MainPage.xaml.cs.  By using the CustomHyperlinkButtonStyle, I was able to run code-free in the code-behind.

TravelReporting Project

This application allows a user to enter a travel report from their phone.  The travel report has two pages of required data.  The user can’t proceed to the second page unless the first page is valid. 

For validation I’m using the declarative (attribute based) validation offered by the Ocean framework.  The validation API’s allow for multiple rule-sets.  This enabled me to have a set of rules for the first page’s fields and a set of rules to validate the entire object on page two.

IDataErrorInfo is not supported in this release of Silverlight for Windows Phone 7.  I have included the interface so that you can have it in place if and when it is supported.  In this simple application, I’m not bothering the user with messages until they press the Next or Save buttons.  When Next or Saved is pressed, the TravelReport object is validated against the appropriate rules.

To see the validation attributes in action, have a look at the TravelReport.cs file.  You’ll also see several rules added in code.

When the travel report is saved it is added to the history file. 

The History page  is accessed from the main page’s menu.  The history presents a list of travel reports and allows viewing the report in detail.

The history file simulates accessing the cloud for historical data.  When the application starts, two travel reports are added to the history file to give you something to look at.


TombstoneSupportPhoneApplicationPage (OceanFramework.Phone)

This is the base class for all my pages.  It adds automatic tombstone activating and deactivating support so that I don’t have to repeat this code on each page.

One challenge developers have is this business of focus not changing when the user presses the back, start, application button or menu.  The problem is, control data bindings do not update their source until lost focus occurs.  Since lost focus does not happen when the user does one of these actions, the user could loose that field’s data that was entered but not committed to the source.  Remember, when a user presses the start button, the application will be tombstoned and if the field’s data was not committed to the model or view model before those objects get persisted, then the data that was entered is lost.

Not to worry.  The below method handles this quirk for you.  Take note of the below TODO.  My current application only has TextBoxes that need this help.  Your applications may need additional tests for other controls.

This method also records the name of the currently focused control so that when the application comes back from tombstonning, the focus field can be restored.

protected override void OnNavigatingFrom(System.Windows.Navigation.NavigatingCancelEventArgs e) {

    // Remove previous focused element
    if (State.ContainsKey(FOCUSED_ELEMENT)) {

    // If an input control has focus, perform an explict binding update.
    // If the user pressed the back button, start button or application button,
    // the binding expression will not process since focus did not change.
    // So... you need to force the binding expression to update so that the
    // model property will be updated.
    var focusedElement = FocusManager.GetFocusedElement() as Control;
    if (focusedElement != null) {

        if (!String.IsNullOrEmpty(focusedElement.Name)) {
            State.Add(FOCUSED_ELEMENT, focusedElement.Name);

        BindingExpression be = null;

        //TODO - Developers, add additional controls here like a date picker, combobox, etc.
        if (focusedElement is TextBox) {
            be = focusedElement.GetBindingExpression(TextBox.TextProperty);

        if (be != null) {

IsolatedStorageFacade (OceanFramework.Phone)

This facade class provides a simple interface for interacting with the IsolatedStorageFile and IsolatedStorageSettings.  You’ll want to modify this to meet you specific needs.

I made all the methods static for ease of use.  If I was using an IOC container, I would provide an interface and inject an implementation.  This would also make testing easier since the implementation could be swapped out.

TombstoneFacade (OceanFramework.Phone)

This facade class provides a simple interface for interacting with the PhoneApplicationService temporary storage state bag.  You’ll want to modify this to meet you specific needs.

I made all the methods static for ease of use.  If I was using an IOC container, I would provide an interface and inject an implementation.  This would also make testing easier since the implementation could be swapped out.


I met with my great friend Laurent Bugnion of MVVM-Light fame this week and spent time taking about Windows Phone 7.  I asked him about globalization of the phone apps.  He explained his solution for using .resx files and I’m sharing it with you.

The Localizer class is a front end that we can instantiate in XAML, then controls can data bind directly to the properties in the .resx file.  This wrapper is required because the .resx class, can’t be instantiated in XAML, even if it is marked public.  This may be a bug, I’ll check up on this.

// Many thanks to Laurent Bugnion http://www.galasoft.ch/ for this cool tip.
// This wrapper around the Strings.resx allows us to data bind to values in XAML
// See App.xaml and MainPage.xaml to see the moving parts.  Very simple solution.
public class Localizer {

    Strings _strings;

    public Strings Strings {
        get { return _strings; }

    public Localizer() {
        _strings = new Strings();

This XAML is from App.xaml.

<infrastructure:Localizer x:Key="LocalizedStrings" />

The below TextBlock displays a globalized string for the application title.  All strings in the TravelReports application are resources.

<TextBlock Style="{StaticResource PhoneTextNormalStyle}"
    Text="{Binding Source={StaticResource LocalizedStrings}, 
           Path=Strings.Application_Title, Mode=OneTime}" />


The download is on my sky drive here.

Remember after downloading a .zip file, you’ll want to right click on the file and “Unblock” the file.  This is the mark-of-the-web that Visual Studio 2010 respects.

Have a great day.

Just a grain of sand on the worlds beaches.


Get every new post delivered to your Inbox.

Join 245 other followers