MVVM and EntityCollection

Posts   
 
    
bjacobs
User
Posts: 73
Joined: 20-Aug-2008
# Posted on: 11-Jul-2009 00:09:52   

I found one post in here referring to MVVM and EntityCollections.

I am able to bind a GridView to an EntityCollection in my ViewModel, but changes to the EntityCollection are not refelected in the UserInterface.

If I bind to an ObservableCollection, when I add and remove objects from the collection my UI is immediately updated.

Is this feature not supported in LLBLGEN collections? If so, can you provide an example? If not, are there any plans to implement this in the future?

Thanks,

Billy Jacobs

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 11-Jul-2009 05:38:01   

Hi Billy,

This may help: http://llblgen.com/TinyForum/Messages.aspx?ThreadID=15204&StartAtMessage=0&#84673

What LLBLGen version and runtime library version are you using? (http://llblgen.com/TinyForum/Messages.aspx?ThreadID=7722)

David Elizondo | LLBLGen Support Team
bjacobs
User
Posts: 73
Joined: 20-Aug-2008
# Posted on: 11-Jul-2009 18:20:57   

The post you linked me to was the post I was referring to when I said I only found one post on MVVM. I must be missing something. flushed The post seems to indicate that the binding should work.

My scenario is similar to the following example: 1. I have a dialog for collection information for a DrugDosageEntity object. 2. This entity has a list of DosageLimits. 3. In my ViewModel I have a dependency property called WorkingDrugDosage. 4. My dialog is databound to the ViewModel. 5. I have several properties bound to the WorkingDrugDosage which all work fine. 6. I have a Grid whose ItemsSource is bound to the WorkingDrugDosage.DrugDosageLimitList_.

If there are any items in the WorkingDrugDosage.DrugDosageLimitList_ initially, they display just fine. However, if I add any new DrugDosageLimitEntities to the list, they do not show in the list until I close and then reopen the dialog.

I am using Adapter Version 2.6.08.1013 Windows Client references SD.LLBLGenPro.ORMSupportClasses.NET20 When I Generate My DataModel I am targeting the .Net Framework 3.5 Have .Net Framework 3.5 SP1 installed.

Thanks,

Billy Jacobs

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 12-Jul-2009 17:31:21   

bjacobs wrote:

If there are any items in the WorkingDrugDosage.DrugDosageLimitList_ initially, they display just fine. However, if I add any new DrugDosageLimitEntities to the list, they do not show in the list until I close and then reopen the dialog.

Could you post the code snippet where you do this? (add new DrugDosaLimitEntities to the list).

David Elizondo | LLBLGen Support Team
bjacobs
User
Posts: 73
Joined: 20-Aug-2008
# Posted on: 13-Jul-2009 17:33:24   

It is in my ViewModel and I do the following:

I pass in a DrugDosageEntity to my ViewModel. When the user fills out a DrugDosageLimit on my dialog that is bound to the ViewModel, they can add it to a temporary list by clicking a button which is bound to a Command on my ViewModel. The CommandParameter is the new DrugDosageLimitEntity they want to add. This adds it to a list in the view model but does not add it to the DrugDosageEntity just yet.

The code for this is: // DosageIntervalLimits is just a temporary list to hold all of my limits until the user saves. DosageIntervalLimits.Add(dosageIntervalLimit); // I reinitialize my WorkingDosageLimit so I can add add the next limit if necessary InitializeWorkingDrugDosageLimit();

When the user has added all of the limits they need, they click the Save Command Button which fires the following in my ViewModel and actually adds the Limits to the Dosage.

foreach (DosageIntervalLimitOnDrugDosageEntity drugDosageLimit in DosageIntervalLimits) drugDosageLimit.DrugDosage_ = DrugDosage;

I do not add directly to the list. I set the DrugDosage_ on the DrugDosageLimitEntity which adds it to the DrugDosageEntity's DrugDosageLimitsList_.

If you want I could create a small sample project to demonstrate the problem.

Thanks

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 14-Jul-2009 09:44:25   

If you want I could create a small sample project to demonstrate the problem.

Yes please.

bjacobs
User
Posts: 73
Joined: 20-Aug-2008
# Posted on: 14-Jul-2009 18:35:12   

Well, I created a test project and it works correctly in the test project. I must be doing something incorrectly. I am investigating.

After investigation it turns out the problem is with the RadGridView from Telerik.

In my test project I used the new WPF DataGrid instead. I will be posting the Test project to the Telerik forums now.

Thanks

Telerik confirmed that this was a bug with the RadGrid control and are fixing in their next internal builds which will be released 7/15/2009.