MVVM and the Infragistics DockManager Control – Part Deux

When I last posted about using MVVM and the Infragistics DockManager Control, I was talking about dynamically adding ContentPane controls to the DocumentContentHost.
In a typical application, some content is used for navigation. In the case of Visual Studio, this can be represented by the Solution Explorer or Class View, enabling a person to jet off to the spot they are looking for. With this Infragistics XamDockManager control, these types of panes exist within the DockManager.Panes collection, but not within the DocumentContentHost. The one concern with navigation panes is that they are typically content-heavy with respect to either processing power or resource usage. To combat this, you’ll likely want not to destroy these panels each time you close them but, rather, simply hide them; to be made visible again at a later time.
Setting the CloseAction property of the ContentPane to "HidePane" (Hide Pain?) partially helps you with this. The problem is that, using MVVM, there’s no way to change the visibility of the pane again to make it visible again. There is, however, a work-around. You can bind the visibility of the ContentPane to a boolean property of your ViewModel, and raise the INotifyPropertyChanged event every time you set the value, rather than trying to (more typically) not raise the value unless the property’s value has changed.
In the attached sample, I am combining some features of PRISM (DelegateCommands) with this to simplify the coding that is occuring. Here is some pseudo-code representing the relevant bits:
In MainWindowViewModel:


MainWindowViewModel() {     

     ShowNavigation =

new DelegateCommand<object>(x => NavigationVisible = true);


public DelegateCommand<object> ShowNavigation { get; set; }

public bool NavigationVisible {

     get { return navigationVisible; }

     set { navigationVisible = value; OnPropertyChanged("NavigationVisible"); }


In Window1:


MenuItem Header="_Control Panel" Command="{Binding ShowNavigation}"/>


igDock:ContentPane CloseAction="HidePane" Visibility="{Binding NavigationVisible, Mode=TwoWay, Converter={StaticResource BoolToVisibilityConverter}}">

<!– Content Here –>



You can find the complete sample here:
Special thanks to Sam of Infragistics for helping me figure out that not declaring Mode=TwoWay makes for a lot of confusion.


MVVM and the Infragistics DockManager Control

Josh Smith wrote a quintessential article on MVVM entitled, WPF Apps With The Model-View-ViewModel Design Pattern, for MSDN Magazine that was published in February 2009. In the article he shows a sample application that some some tabs and displays some content. Sounds pretty simple until you consider that the content of the tabs is dynamic and could be anything. The sample app demonstrates a little trick I thought was brilliant and made the entire article so eye-openning; using DataTemplates to bind the possible dynamic sources of Views and ViewModels together, allowing the page controller (host view model?) to simply maintain a bound collection of viewmodels and have the XAML do the figuring of what view to display. This is a fantastic example of Separation of Concerns.
Though I really loved the article, I wanted to leverage the UX functionality of the Infragistics DockManager control to give the user more flexibility in how they want to view the data being presented (especially in a multi-monitor scenario). Using the source code from Josh‘s article as a base and swapping out the TabControl he was using with InfragisticsDockManager control failed as there isn’t a way to natively bind the DockManager to the collection of ViewModels hosted in the page controller (host view model?). The support from Francis and Sam from Infragistics lead to soliciting help from Andrew Smith who graciously wrote a blog post entitled "ItemsSource for XamDockManager Elements" demonstrating how to accomplish the required binding. (Source code available here)
All of this culminates in the successful marryiage of the dynamic nature demonstrated in the MVVM pattern demonstrated in Josh‘s article with the flexibility of the Infragistics DockManager control. I have posted the sample source code here.
Many thanks need to be extended by myself and on behalf of the users of the application I am working on for the efforts of Francis, Sam, and Andrew from Infragistics as well as the ground-breaking of Josh for bringing this all together.

Unit testing publishing events from the event aggregator in PRISM

Coming back from the holiday, my mind was a still in a fog as to how to get an event, exposed by the event aggregator to fire and test the results. This is a quick shout out of thanks to Nikola Malovic for his Prism (CAL) unit testing – How to test Prism (CAL) Event Aggregator using Rhino Mocks post I was able to get on track again quickly. The subtle key to the post is that the events being published are NOT mocked objects.

WPF & MVVM: DataBinding UserControl Command to Parent DataContext

I had been struggling with figuring out how to make the my XAML databinding force the command of a user control be handled by the ViewModel of the parent window in which it is contained. In an effort to follow SRP I wanted the behavior of the ViewModel of the parent window to be more of a PageController and the ViewModel for each contained UserControl follow a more pure ViewModel pattern. I was fortunate to be in contact wtih Steven Robbins via twitter (@GrumpyDev) which lead me to discover the blog post, Wpf: Binding to parent property (RelativeSource Ancestor DataContext), by Jeffrey Knight (Twitter: @jeffreyknight).
You can download the sample scenario I created here.

MVVM Pattern – A Consolidation of Resources

I am just getting started with the MVVM Pattern.  I have been accumulating information that is starting to spill over. I figured it was time to consolidate the information into a post.


Model-View-ViewModel Pattern


Introduced in 2005 by John Gossman, the Model-View-ViewModel pattern enables loose coupling between the view, its related code, and the model, resulting in increased testability, flexibility, and maintainability of the application.

Jason Dolinger, Senior Engineer at Lab49 has an excellent presentation (1hr 30min) on the evolution of building MVVM applications from a classic WinForms perspective to using MVVM as well as a blog post that contains links to the original source code for the presentation.

In his presentation, Jason ignores the ‘Model’ component of the MVVM pattern. Josh Smith and Craig Shoemaker‘s MVVM video for WPF addresses the relationship between the Model and ViewModel (as well as other things).


Additional Resources


Publishing ClickOnce Applications to Run Side-by-side for Different Environments from the Command Line using Nant

The following information relates to .NET 3.5 and NAnt 0.85.
I struggled with this for quite some time. I was trying to run a command-line, clickonce deployment of my application to enable it to run side-by-side for the different environments (development, quality assurance, user acceptance testing, and production). Kavinda Munasinghe’s blog post, Deploying ClickOnce on Multiple Environments was a fantastic start. It also referenced a former coworker, Neil Bourgeois, and his post, Click Once deployment using NAnt. Neil’s article looked like too much manual lifting as MSBuild should have the ability to take in some command-line parameters to do this properly as it is possible to accomplish the goal os side-by-side applications if performed within visual studio. The problem was figuring out which command-line switches to pass to MSBuild to get it to work.
The Keys are 3
  1. ProductName – This will identify each instance uniquely. I would recommend indicating each instance by its target environment to help users know which one they are running as well as knowing which one they are uninstalling if using Add/Remove Programs. e.g. <Product Name> – Development
  2. SignManifests – This was the one parameter missing from Kavinda‘s post that was forcing the value for publicKeyToken (a part of the application identity that must be unique to allow the applications to run side-by-side) to always remain at a value of "0000000000000000".
  3. ManifestKeyFile and ManifestCertificateThumbprint – These values are what are used to actually sign the manifest. These were what Kavinda was correctly noting in the article.

The Result

I have one exec task in my nant script that takes in parameters that are set by running a target specific to the intended environment:

<!– deployment properties –>
property name="" value="My Company Name" />
property name="publish.output.base.dir" value="\UNCLocationDeploymentProductName" />
property name="" value="ProductName" />
property name="" value="SET_BY_TARGET__DO_NOT_CHANGE_HERE" />
property name="build.label" value="SET_BY_TARGET__DO_NOT_CHANGE_HERE" />
property name="publish.output.dir" value="SET_BY_TARGET__DO_NOT_CHANGE_HERE" />
property name="manifest.certificate.thumbprint" value="SET_BY_TARGET__DO_NOT_CHANGE_HERE" />
property name="manifest.key.file" value="SET_BY_TARGET__DO_NOT_CHANGE_HERE" />

<target name="">
property name="publish.output.dir" value="${publish.output.base.dir}Development"
property name="manifest.certificate.thumbprint" value="003dd8c1fca443b398d240a54a7e47f2"
property name="manifest.key.file" value="certificatesdevelopment.pfx"
property name="" value="${} – Development"
call target ="deploy.common"

 <target name="deploy.common">
exec program="MSBuild.exe"  
              commandline=MyProject.csproj /target:rebuild;publish /property:ProductName="${}";
                                     Platform="Any CPU";
                                      /nologo /verbosity:quiet basedir="${framework.dir}"/>

There are a few extra items in there that force this application to be installed locally as well as always remain at the latest version that are not applicable to this post, but I am leaving them in there for completeness.


Adventures in Installing Adventureworks Database on SQL Server 2008 Express

I was wasting plenty of time trying to get the AdventureWorks Database Samples installed on SQL Server 2008 Express this afternoon. The problem was, 1) that the Full-Text Search service does not install via the Microsoft Web Platform Installer, 2) FILESTREAM was not installed, 3) MSI installer for AdventureWorks Database Samples failed fast and wouldn’t install the databases.
  1. Uninstall SQL Server 2008 Express installed by the Microsoft Web Platform Installer and, instead, download Microsoft SQL Server 2008 Express with Advanced Services and install it as per this SQL Server Development Center Forum thread (this installer gives you a LOT more options than the web install!!!). Though, in hindsight, I figure I could have likley simply installed Cumulative update package 2 for SQL Server 2008 as per the FIX: Full-text search functionality does not work in SQL Server 2008 Express Edition article. I did not test just installing the cumulative update. YMMV
  2. Folow the instructions from the How to: Enable FILESTREAM MSDN article (this option can be enabled during the installation of Microsoft SQL Server 2008 Express with Advanced Services).
  3. Because the installer failed, (see fail messag below) I downloaded the zip file and edited the install<X>db.sql script located in the folder of each of the different databases you can install. The things I had to edit:
    • :setvar SqlSamplesDatabasePath (line 39) (to "C:Program FilesMicrosoft SQL ServerMSSQL10.SQLEXPRESSMSSQLDATA")
    • :setvar SqlSamplesSourceDataPath (line 40)  (to "C:<unzip folder>ToolsSamples" e.g. "C:tempadventureworksToolsSamples")

           Then I ran the script from the command line by executing sqlcmd -S <machine name>SQLEXPRESS -i instawdb.sql

Adventureworks successfully installed… finally!


AdventureWorks Installer Fails:

  1. After selecting database instance, the next button is not enabled until you select the database instance, then click back, then click next to come back to this screen.

     2. And then receiving the ended prematurely dialog with the gracious opportunity to finish with no further information.


Cursory Look at WPF Control Suite Vendor Offerings (Part 2 of 2)

I conducted an investigation into WPF control suites for my client. I was graciously permitted to present the information I was able to drum up from the different vendor’s websites. 

Apology: Live Spaces has a size limit for their blog posts ("This entry contains too much text. Please remove some text, and then publish this entry. To publish more text, add a new entry.") so I had to publish this in two posts. Vendor Suites in previous post: ComponentOne, Telerik, Actipro, Xceed, DevExpress. 


Product: NetAdvantage for WPF – Online Demo

Includes: Data Grid, Carousel, Data Presenter, Chart, Carousel Listbox, Carousel Panel, Dock Manager, Month Calendar,Outlook Bar, Tab Control, Ribbon, Editors, Excel Export/Import, Reporting.

  •  includes all controls, subscription services, updates, upgrades and new product releases for one year and C# source code for all Windows Forms and WPF controls and designers

Licensing : 

  • Per developer @ $995.00 USD Renewal @ $495.00 USD
  • Per developer @ $1490.00 USD with one year of priority phone, 24-hour chat and rapid response online support. Renewal @ 749.00 USD



Product: Essential Studio WPF Edition – Online Demo

Includes: Data Grid, Tools – Ribbon/Docking/Editors/Menus/MDI, Chart, Diagram, Editors – with highlighting, Gauge.
Licensing : 

Binary Mission

Product: UI ControlSuite .NET Enterprise edition

Includes: Slideshow, Control resizer, ScrollViewer and ScrollBar, Grid and TreeListView, Ribbon, UI Virtualizing WrapPanel, Content flip / rotation capable Content control, Tab/Navigation, ListBox, and Color picker.

Licensing : 



Product: Nextwave Suite 2.5 for WPF – Dashboard Samples

Includes: Chart for WPF, and Nextwave Gauge for WPF


Cursory Look at WPF Control Suite Vendor Offerings (Part 1 of 2)

I conducted an investigation into WPF control suites for my client. I was graciously permitted to present the information I was able to drum up from the different vendor’s websites. 

Apology: Live Spaces has a size limit for their blog posts ("This entry contains too much text. Please remove some text, and then publish this entry. To publish more text, add a new entry.") so I had to publish this in two posts. Vendor Suites in next post: Infragistics, Syncfusion, Binary Mission, Nextwave.



Product: Studio for WPFOnline Demo

Includes: Chart, Gauges, Grid, HyperPanel, MaskedTextBox, NumericBox, RangeSlider, Reports,Scheduler.

Licensing :  

  • Per developer @ $1100 USD – Source code is NOT included or available for WPF control set.



Product: RadControls for WPFOnline Demo

Includes: Calendar, Carousel, Chart, ColorPicker, ComboBox, DatePicker, Docking, Drag & Drop, Expander, Gauge,GridView, Masked Textbox, Numeric Up/Down, OutlookBar, PanelBar, ProgressBar, Scheduler, Slider, TabControl,TileView, TimePicker, ToolBar, TreeView, Window.

Licensing : 

  • Per developer @ $999 USD – Source code included in the Developer License with Subscription and Priority Support option. (@ $999 USD /developer)


Product: WPF Studio for WPFOnline Demo

Includes: Bar Code, Data Grid, Docking and MDI, Editors, Guage, Navigation, Property Grid, Ribbon, Syntax Editor,Wizard, and Shared Library

Licensing :  

  • Per developer @ $649 USD for first and 10% off for each additional license up to 8 licenses
  • Site License @ $4,999 USD | Organization License @ $9,999 USD
  • Option to add source code (Blueprint) to any of above options for $1499 USD
  • Renewals of Per developer License @ $389 USD for first and 10% off for each additional license up to 8 licenses


Product: Xceed Ultimate SuiteOnline Demo

Includes3D Views, DataGrid (professional), DataGrid (standard), Editors, Glass Theme, Media Theme, Office 2007 Theme, Professional Themes
Licensing : 

  • Per developer @ $999.95 USD
  • Per developer with Updates @ $1499.95 USD
  • Per Developer Source code included (Blueprint Edition) @ $1,999.95 USD
  • Renewals Per developer 1 year vanguard @ $599.95
  • Renewals Blueprint Edition @ $999.95



Product: DevExpress WPF Product LineOnline Grid Demo

Includes: Data Grid, Charting, Toolbar-Menu System, Dock Windows, Printing-Exporting Library, Data Editors, Navigation Pane, and Carousel.
Licensing : 

  • DXperience WPF Edition : 
  • DXperience Enterprise Edition (with source code) : 
  • DXperience Universal Edition (with source code) : 
  • Automatically receive all updates for those products which you are licensed under a given subscription

Getting started with Model-View-ViewModel (MVVM) in WPF and Silverlight

In my continued investigation of WPF, I came across a FANTASTIC (downloadable) presentation and associated blog post (where you can download the code if you want) by Jason Dolinger on WVVM in WPF. I’m fairly certain the presentation content is easily portable to Silverlight.

For me the best part of this presentation is that it takes you from the Win/Web-Forms world to WVVM through a series of refactoring steps and very clearly illustrates the advantage of this technique and making applications testable and loosely coupled. Kudos Jason!

Update: One thing that Jason ignores in his screencast is the ‘Model’ component of MVVM. More on that aspect can be found in Josh Smith and Craig Shoemaker‘s MVVM videos that can be viewed here (WPF or Silverlight) or downloaded here (WPF or Silverlight).