Up Reference apps and tutorials

The Happy Hour Tutorial

Last modified on February 21, 2012 14:55

If you’re new to Cocktail, you've come to the right place. 

Belly up to the Happy Hour bar, a Silverlight application (v.4 or v.5) that you'll build from scratch. MVVM, convention over configuration, view composition, screen navigation, data repositories … they are all introduced here in short, easy-to-follow lessons that build progressively from a blank solution to a plausible application.

This series gets you started with Cocktail, guiding you towards proven architecture and practices that will sustain your application over time. We show you how … and we explain why.


Getting started

Download Cocktail, install the tools, and get ready to start developing XAML-based business apps.

Bare bones MVVM

Build a simple app with a single view. Migrate the supporting view logic out of the code-behind and into a homebrew ViewModel.

An MVVM Cocktail

Take that same app and introduce it to Cocktail. Boilerplate handwritten code melts away as Cocktail conventions do the wiring for you. Maybe this MVVM thing isn’t so complicated.

Conventions and diagnostics

Conventions seem like magic. What happens when the magic fails?  We learn more about conventions and discover that Cocktail is logging to the output window as the conventions are applied. Knowing how to interpret these logs will help you diagnose problems

Data in a ListBox

We create a model with a single entity, a DrinkOrder, representing a tasty beverage ordered from the bar. Each ordered drink appears in a ListBox, its values bound to controls in an ItemTemplate in the same conventional manner we’ve seen so far.

Entity Views

We discard the ItemTemplate in favor of View class. DrinkOrder serves as its own ViewModel. We add a new convention so Cocktail can associate a View with an entity in the Model. In fact, a ViewModel can have multiple Views.

Talk to the View

Some View behaviors can be clumsy to stimulate with View/ViewModel binding. Although it offends the purists, we revive the View code-behind and teach the ViewModel to call into the View via an interface

Images and ValueConverters

Modern application data includes pictures. In XAML you need a ValueConverter to translate from picture representation in data (typically as a source string) into images on screen. We see how Cocktail conventions can embed customizable image ValueConverters in the bindings.

More to come

Stay tuned for lessons covering these topics:

  • Animation with the ViewStateManager
  • Pesky ComboBoxes
  • ItemViewModels add UI aspects to entities
  • Master/Detail views
  • Launch a customizable dialog
  • Tame dependencies with dependency injection
  • Test the ViewModel
  • Build a “Code First” relational data model 
  • Access data asynchronously with a Repository
  • Sequence asynchronous calls with CoRoutines
  • Search and page results
  • Edit and save changes
  • Isolate edits in a “sandbox”
  • Coordinate multiple screens
  • Cancel a screen close
  • Communicate among ViewModels with EventAggregator

Created by DevForce on January 31, 2012 16:57

This wiki is licensed under a Creative Commons 2.0 license. XWiki Enterprise 3.2 - Documentation. Copyright © 2012 IdeaBlade