Wpf Data Binding Issue: ListView not updating when selected entity is re-fetched.

Posts   
 
    
scaless
User
Posts: 22
Joined: 28-Mar-2011
# Posted on: 31-Mar-2011 22:36:53   

I ran into a strange issue while evaluating LLBLGen Pro. I was testing the data binding with WPF, and found that when I refresh the selected entity from oracle (DataAccessAdapter FetchEntity method), the SelectedEntity property in the ViewModel gets updated, but the ListView does not get updated.

My view is a simple test against a test table I created. It has a ListView and a selected record detail section. The ListView's ItemsSource property is bound to a collection in the ViewModel called Entities and the SelectedItem property is bound to a property in the ViewModel called SelectedEntity.

The detail section is a few text boxes bound the individual properties on the ViewModel's SelectedEntity property.

When I update the selected entity through either code in the ViewModel, or in the GUI Detail section, the update displays in the ListView and the Detail section as it should. When I call the FetchEntity again to refresh the entity from the DataBase, the ListView does not reflect the changes. The textbox's in the detail section do however.

To work around this I create a new Entity object passing in the primary key of the ViewModel's SelectedEntity property, then call the DataAccessAdapter FetchEntity collection. Then I remove the SelectedEntity from the Entities collection and replace it with the newly fetched entity within the Entities collection. This causes the ListView to update as it should.

I was just curious why it behaves that way. One would think that if you want to revert changes and restore your in memory record to the same state as in the database, the binding should update the UI.

LLBLGen Pro V: 3.1 Final - TRIAL Runtime Library V: 3.1.11.318 **.NET Version: **4.0 Template Group: Both Adapter Oracle V: 10g Oracle Clieng V: 11.1 **Inheritance Hierarchies: **None **OPD Oracle.DataAccess.dll V: **2.111.7.20

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 01-Apr-2011 02:39:37   
David Elizondo | LLBLGen Support Team