This project has moved. For the latest updates, please go here.

How to build Hierarchical ViewModel using MEF

Apr 7, 2014 at 2:12 PM
I've been trying to build hierarchical view model for the purpose of using WPF Treeview in my application but no success. I use Prism+MEF as framework for my application and I tried very hard to include Treeview control as per Josh Smith article here but I don't know how to build that nested structure with MEF and without using new operator.
So I wish that some guru here can show us how to do it based on that example.
Thanks in advance
Apr 7, 2014 at 11:49 PM
What exactly are you looking for? Do you want the tabs in the UI to be plugins?
Apr 8, 2014 at 11:30 AM
Edited Apr 8, 2014 at 11:31 AM
Based On that sample how can I build the hierarchy of the View Models for example in the LoadOnDemand tree how to build CountryViewModel which wrap the RegionViewModel which wrap the StateViewModel ... etc. how to build such nested structure using MEF and eliminating the new operator.
Apr 11, 2014 at 8:57 AM
at least could anybody implement the following two classes using MEF and I will follow up for rest of the sample
public class CountryViewModel
readonly ReadOnlyCollection<RegionViewModel> _regions;
public ReadOnlyCollection<RegionViewModel> Regions
get { return _regions; }
public CountryViewModel(Region[] regions)
_regions = new ReadOnlyCollection<RegionViewModel>(
(from region in regions
select new RegionViewModel(region))

public class RegionViewModel : TreeViewItemViewModel
readonly Region _region;
public RegionViewModel(Region region)
: base(null, true)
_region = region;
public string RegionName
get { return _region.RegionName; }
protected override void LoadChildren()
foreach (State state in Database.GetStates(_region))
base.Children.Add(new StateViewModel(state, this));