Detail Viewmodel for BusinessListBase<OrderList, Order>

Detail Viewmodel for BusinessListBase<OrderList, Order>

Old forum URL:

Imker posted on Monday, February 28, 2011

I read Rockys blog entry

CSLA .NET 3.8 Beta 2 MVVM support at least a dozen times.  Good stuff,

and I managed to get the basics working.


this is my first try with basic MVVM using the CLSA Viewmodel and TriggerAction.


I have a root object Orders, that is a list of children, Orders.


I managed to create a Viewmodel for the OrderList, and a Viewmodel for the single Order, which I'd like

to use as viewmodel for the detailregion to edit/delete the single order.


The OrderListViewmodel works great and I can use Save and AddNew without any code behind,

to save the list, and add new orders to it. Clean Code!

But I have problems whith the detail region of the order, I createt an OrderViewModel, after the

example of the LineItemsViewModel.

Rocky gave this as example:

<Grid Name=”ChildRegionContainer”> 
    <this:LineItemsViewModel x:Key=”LineItemsViewModel” 
                                           Model=”{Binding Path=Model.LineItems}”/> 
  <Grid Name=”ChildRegion” DataContext=”{Binding Source={StaticResource LineItemsViewModel}}”>


as my orderlist has no LineItems Property, I bound the child model directly to Model.

    <this:OrderViewModel x:Key=”OrderViewModel” 
                                           Model=”{Binding Path=Model}”/> 

when I check the Model of Orderlist viewmodel ist a collection of order children. But the detail region shows no Orderdetail.

I think when I want to delete a specific order I need the detail viewmodel for the specific children order?

Or what is the easyes way to tell the viewmodel what order to edit in the detailregion, or what

order to delete from the orderlist?

MVVM is great, but the real use can be pretty strange the first time around.








Imker replied on Monday, February 28, 2011

I think i learned some new things by studing the MvvmExperiment Sample.

I modified the OrderListViewModel so it contains a SelectedOrder-Property, set via

TriggerAction. then I bindthe OrderViewModel on the OrderlistViewModel, Path=SelectedOrder.


Is this the correct way, or is Rockys way as written in the blog completely different?


RockfordLhotka replied on Tuesday, March 01, 2011

I agree, it can take some effort to get into the right mindset to make MVVM really work.

One thing I always keep in mind is that the "viewmodel layer" can interact with itself freely. In other words, viewmodel objects can create and interact with each other as necessary.

And a viewmodel can create and interact with model objects, though for the purposes of binding a viewmodel usually has one model object.

Model objects (business objects) can interact with each other all they want, but they can't directly reference or interact with a viewmodel. Any interaction with a viewmodel should be done through standard events (INotifyPropertyChanged, etc).

In a simple case a viewmodel might contain a BLB, and expose it as a Model property.

But if you need to add verbs to each item in the BLB, then you need to wrap each item in its own viewmodel.

In that case the "root" viewmodel will create or get the BLB, and it will expose a collection of viewmodel objects, where each of these viewmodels wraps one item in the BLB. The view binds to this list of viewmodels.

I show this in the CSLA 4 MVVM video series.

Imker replied on Tuesday, March 01, 2011

Rocky, thanks a lot.

I learn most from simple and concise samples addressing one issue at a time. MVVMexperiment is a good learning place.

Then I learned to set 

ManageObjectLifetime = false for children ViewModels to avoid the EditLevel problem.

Is there a place to download the CSLA 4 MVVM Video SOURCE samples? That would ease things for me a lot.


RockfordLhotka replied on Tuesday, March 01, 2011

The sample code for the videos is available from the download page for the videos.

Imker replied on Wednesday, March 02, 2011

Why are the samples only available if you pay for the videos?

RockfordLhotka replied on Wednesday, March 02, 2011

The videos and their related samples are a single product.

Copyright (c) Marimer LLC