Wintellect Blogs

Advanced Silverlight Applications using the Managed Extensibility Framework

Jeremy Likness

15 Apr , 2013  

This week I had the pleasure of attending my first CodeStock event in Knoxville, TN. Let me start by saying it was an amazing event. I give many thanks to the attendees, for keeping it a strong and thriving community, the sponsors (including my company, Wintellect), the speakers, and of course the organizers. You can learn more about the event at the page I linked to above. I highly recommend it – great venue and setup, and fantastic people. I connected and made friends with many people in both the .NET and programming community in general.

X-Fit Sample Application

For my talk on advanced applications in Silverlight using the Managed Extensibility Framework, I built a sample application called “the X-Fit Sample Application.” I often hear complaints that demos and blog posts focus on one screen and a button. I wanted to build something with more depth than that, and used that application for my presentation.

What does it demonstrate?

  • Region management
  • De-coupling of views and view models
  • Dynamic loading of XAP files on-demand
  • OOB (Out-of-Browser)
  • Recognizing out of browser and behaving differently
  • Loading a plugin from the file system
  • Messaging using MEF
  • “Tracing” using Debug
  • Debugging MEF parts (imports and exports)
  • …and plenty more

You can click here to view: X-Fit Sample Application

The source code and slide shows from my deck are both available at this link:

Deck and source

To use the application, jump into it and fill out the information.… Read more

,

Wintellect Blogs

Coroutines for Asynchronous Sequential Workflows using Reactive Extensions (Rx)

Jeremy Likness

15 Apr , 2013  

I’ve been doing quite a bit with Reactive Extensions (Rx) for Silverlight lately. One idea that I keep exploring is the concept of creative intuitive sequential workflows for asynchronous operations. You can read about my explorations using Wintellect’s own Power Threading Library in this post along with a simple solution using an interface and enumerators in part 2 of that series. I’m tackling the problem from a different angle.

First, my disclaimers: this is more of an exploratory, “Here’s what can be done” post. Please don’t take this as best practice or guidance, but more of another way of looking at the solution as well as an opportunity to dive deeper into Reactive Extensions. Also understand I am by no means an expert with Rx so I welcome feedback related to this experiment.

The concept is straightforward: there are often times we want an asynchronous set of operations to perform sequentially. Perhaps you must load a list from a service, then load the selected item, then trigger an animation. This can be done either by chaining the completed events or nesting lambda expressions, but is there a cleaner way?

To me, a cleaner solution would make it easy to see what happens sequentially, and also easy to fire the sequence.… Read more

, ,

Wintellect Blogs

Fundamentals of the Managed Extensibility Framework

Jeremy Likness

15 Apr , 2013  

I’ve been building enterprise applications for more than a decade now, and have specialized in Silverlight line of business applications for the past several years. The term “enterprise” seems to inspire images of complex, large, difficult-to-maintain software systems but a well-written system doesn’t have to suffer from the extra complexity. One question I receive over and over again is what a good resource is to learn best practices for building Silverlight applications that target line of business. The market is just now starting to come out with books and tutorials that address these topics but for the longest time you had to scour to find most of your information in blog posts or tweets. I decided to take on two projects to fill two very specific gaps and I’m excited to share the details with you in this blog post.

The first project reaches past Silverlight and addresses a framework I believe was game-changing when introduced with .NET 4.0: the Managed Extensibility Framework (MEF). I partnered with Addison-Wesley to produce a LiveLessons video series and ended with over 4 hours covering the fundamentals of MEF.

I learned about the Managed Extensibility Framework (MEF) when it was in early preview. The first project that I used it for that went to production was the 2010 Winter Olympics in Vancouver.… Read more

Wintellect Blogs

Video: Getting Started with Jounce MVVM and MEF for Silverlight 5

Jeremy Likness

22 Jan , 2012  

I created a quick video to help you get started with using Jounce. The video starts with a blank slate, steps through installation of Jounce and the creation of a sample view model for a simple contact record that includes validation.

You can access the video directly at http://vimeo.com/jeremylikness/jounce-getting-started, or view it below:

Jounce: Getting Started from Jeremy Likness on Vimeo.

Jeremy Likness

Read more

, ,

Wintellect Blogs

Jounce 2.0 MVVM with MEF for Silverlight 5 Released

Jeremy Likness

21 Jan , 2012  

I’m pleased to announce the official release of Jounce 2.0 for Silverlight 5. There are quite a number of new features available that I’ll review in this post. Most significantly, of course, the code base has been updated specifically to target Silverlight 5. A number of bug fixes, feature requests, and Silverlight 5 features have been added. The DLL for Jounce is still just under 100 KB for release so it remains nimble and lightweight.

There are two ways you can install the latest. Zip over to Jounce at CodePlex to download the binaries and/or the full source. Or, jump into NuGet and install the Jounce package. The package is set up to wire in a default application. To get this functionality, follow these simple steps:

  1. Create a new Silverlight application. I recommend the basic “Silverlight Application” template as I haven’t tested with any others, and it doesn’t matter if you host it in a web site and/or choose to use WCF RIA services.
  2. Delete the App.xaml and MainPage.xaml files. Trust me on this one.
  3. Jump into the package manager console and type Install-Package Jounce.
  4. Hold down CTRL and press F5 and you should see a welcome message. That’s it.
Read more

, ,

Wintellect Blogs

Creating a Markup Extension for MEF with Silverlight 5

Jeremy Likness

14 Apr , 2011  

One exciting new feature of Silverlight 5 is the ability to create custom markup extensions. Markup extensions are a part of XAML. Whenever you see a notation that starts and ends with a brace, you are viewing a markup extension. Markup extensions exist to pass information to properties in the XAML that the XAML parser can use when generating the object graph.

A commonly used example of markup extensions is the data-binding syntax. In the following XAML snippet, the data-binding uses a markup extension to specify that a binding is being defined.

<TextBlock Text="{Binding Path=Name,Mode=TwoWay}"/

The brace begins the extension, followed by the name of the class that will handle the extension, followed by any parameters you wish to pass. You can do that same thing in code behind by creating a Binding object directly and setting it’s properties.

So how are markup extensions useful? They provide a hook to perform functionality that would be impossible or overly complicated using traditional approaches such as attached properties or behaviors. One popular use of markup extensions is to provide access to static classes that otherwise are not available in XAML. A common reason to do that would be to access a service locator – for example, to generate your view model.… Read more

,

Wintellect Blogs

Announcing Jounce 1.0 RTM – It’s here!

Jeremy Likness

30 Mar , 2011  

Jounce is the result of building composite Silverlight enterprise applications for a variety of verticals since Silverlight 3.0 and finding the common problems that needed to be solved. I found many frameworks to be too heavy for the task and always wondered why more did not tap into the native advantages that the Managed Extensibility Framework brings. So, I began porting my framework around as a core engine for projects and finally decided to make it available to provide guidance for building these types of applications using the MVVM pattern and MEF.

You can see concepts about Jounce echoed in many of my posts, but the easiest way to summarize the post-release topics is to follow the jounce tag on this blog. While bits and pieces have been posted over time, probably the first comprehensive peek at what Jounce would look like happened as the result of my 2010 CodeStock presentation. I posted an application called XFit to demo a live modular application that was more than just a button and a text file. Over time that has been refined and advanced through input from the community as well as fellow developers who are using Jounce in their own projects.

I’d like to give special thanks to Page Brooks for giving Jounce a logo, adding tests, testing the heck out of it and also giving us a wonderful project template (available on the downloads page).… Read more

,

Wintellect Blogs

Jounce Part 14: Using MEF for Non-Shared Views and View Models

Jeremy Likness

27 Mar , 2011  

Even if you don’t use Jounce, this post will help you better understand how to create non-shared views and view models with the Managed Extensibility Framework (MEF). The architecture I prefer in Silverlight is to keep a shared view and view model where possible. If only one instance of the view is visible at a time, the view model can be manipulated to provide the correct bindings and information when different data is selected for that view. Keeping a single view avoids issues with waiting for multiple views in garbage collection or keeping track of multiple views that might not unhook from the visual tree correctly.

There are several cases where this is not plausible. In a master/detail scenario with dockable views, you may end up with multiple “detail” views on the screen. Each view requires a separate copy and possibly a separate view model as well.

Lazy Shared Views and View Models

In MEF, the Lazy<T,TMetadata syntax is used to import multiple implementations of a contract and associated metadata. The pattern allows you to inspect the metadata before creating the object instances, so you have full control over what is happening. Jounce uses this feature to bind views and view models by inspecting the metadata and using that to examine “routes” created by the user (a route simply asserts that view “X” requires view model “Y”).… Read more

Wintellect Blogs

Jounce Part 11: Debugging MEF

Jeremy Likness

24 Feb , 2011  

The Jounce framework specifically relies on the Managed Extensibility Framework to help solve MVVM concerns. I recently presented an introduction to MEF and explained what I believe are the four core problems it solves:

  1. Discovery — it’s good to decouple, but at some point you need to provide an implementation, and MEF does a great job of discovering implementations, wiring their dependencies, and providing them to you
  2. Lifetime management — instead of mangling classes to follow the singleton pattern, MEF provides you with a way to manage the lifetime of those classes through attributes. You can define whether or not an instance is shared or generated both where you define the class and when you require it, giving you plenty of flexibility over how the class is managed without having to change it
  3. Extensibility — this often throws people off because they believe it is just for plug-ins. The fact is MEF has a very easy, built-in means for dynamically loading XAP files and integrating them into your main application, making modularity and extensibility easy to implement
  4. Metadata — Jounce uses this extensively: the ability to tag an implementation with additional data and filter that data to route implementations and only create them on demand when needed.
Read more

,

Wintellect Blogs

Jounce Part 9: Static and Dynamic Module Management

Jeremy Likness

8 Jan , 2011  

One popular feature in the widely used Prism Framework is the concept of “modules.” A prism module is a functional unit that represents a set of related concerns. These concerns can be coded and tested independently and then composed into larger applications. They can also handle dependencies with other modules and be discovered and dynamically loaded.

While the concept worked well for WPF and prior versions of Silverlight, Jounce takes a slightly different approach that recognizes and uses two features that are built into Silverlight. The first is the concept of a XAP file, which is nothing more than a ZIP file with a manifest that lists resources and contains the resources themselves (typically DLLs, images, embedded fonts and data). Jounce treats XAP files as the perfect medium to encapsulate a module within Silverlight. The second feature is the MEF DeploymentCatalog which allows Silverlight to dynamically load and compose parts from a XAP file.

Creating a Module

To create a module with Jounce is incredibly simple: fire up Visual Studio and create a new Silverlight Application. That is a module!

There will always be exactly one module that is a “host” module. This module must contain the App.xaml.cs code and the initial reference to the Jounce ApplicationService in order to start the application and initialize the Jounce framework.… Read more

,