CSLA 3.8, Silverlight, MVVM question

CSLA 3.8, Silverlight, MVVM question

Old forum URL: forums.lhotka.net/forums/t/8427.aspx

Fele posted on Thursday, January 28, 2010

I'm implementing page that have two datagrids with couple selection fields for each of them.
I created one VMB (ViewModelBase) that points to BB with selection fields properties and two server calls, one for each datagrid.
At this point, I'm able to  populate each of datagrids separately. However, if I populate first one and then I want to populate second, I'm loosing data (datagrid and selection) in the first one.

Is Csla doing it?
If yes, why?

I was thinking about set up separate VMB for each datagrid and selection fields associated with it. I like idea but I can't figure out how to pass data between two VMB's (this is why I decided to implement one VMB).

I appreciate any suggestion how to make my page working.

RockfordLhotka replied on Thursday, January 28, 2010

Data binding typically maintains one "currency" for each binding source. I suspect what you are seeing here, is that you are trying to have one binding source (the VMB) that is bound to two controls (the datagrids) that both want to maintain currency. That is probably confusing data binding.

That's just a guess, and it would depend a great deal on how your binding and VMB are implemented.

For my part, I'd probably use two VMs, and chain them using data binding. That's how you connect one VM to another.

Assuming both VM objects are resources, declare the first one first and the second one second. Then use a binding expression to set the Model property of the second one to the appropriate property of the first one to get the model.

I do this in the MVVMExperimentSL sample project

    <this:DataListViewModel x:Key="ListModel" />
    <this:DataViewModel x:Key="DetailModel" Model="{Binding Source={StaticResource ListModel}, Path=SelectedData}"/>


Fele replied on Thursday, January 28, 2010


Copyright (c) Marimer LLC