views:

17

answers:

1

Environment: VS2010, SL4, RIA Services

I have an SL4 UI that I developed against data objects that were instantiated from an XML file (so that I didn't have to worry about the back end of the app while I worked on the front end). In this UI, I have a data grid that shows properties for each object in the collection of data. I also have a details panel that shows editable details for the object that is selected in the datagrid.

In this version that uses the "mocked" data, I have the binding for the editable properties set as TwoWay. When I edit a value in the details panel, the corresponding value in the data grid is updated. (I don't allow editing directly in the grid.) I can move to another record, then return to record I changed and I can see that the value has successfully been changed (on the client side, at least).

I then added RIA Services to the mix so that I am now retrieving the data from the back end. The data loads fine, but when I try to modify the value of a property in the details panel, it doesn't "stick". That is, the value in the data grid doesn't update to reflect the new value and if I move to another record and return to the changed record, the old value is shown.
Since RIA Services is the thing that changed, I'm assuming that that's where the problem lies.
Next step... I placed a break point in the code generated by RIA Services for client-side consumption inside the setter for the value that I'm changing. When the data is first loaded, the code in the generated setter works fine. When I make a change to the property, however, there appears to be a problem.

Here is the generated code in the setter:

        set 
        { 
            if ((this._quantity != value)) 
            { 
                this.OnQuantityChanging(value); 
                this.RaiseDataMemberChanging("Quantity"); 
                this.ValidateProperty("Quantity", value); 
                this._quantity = value; 
                this.RaiseDataMemberChanged("Quantity"); 
                this.OnQuantityChanged(); 
            } 
        }

After changing the data, I step through the above code in the debugger. When I execute the "RaiseDataMemberChanging..." line, the setter is exited and the rest of the statements are not executed. No exception appears to be thrown and the app continues, but the value isn't updated because the line of code in the setter that sets actually sets the value doesn't appear to be executed.

Any ideas on what the problem is (or at least what I should try next)??

Here is some additional information that may be helpful:

The editing happens in a text box in the details panel. Here's the Xaml for the text box:

<TextBox Grid.Row="2" Grid.Column="0" Text="{Binding Quantity, Mode=TwoWay}" />

Here's the binding used in the data grid. (I don't allow editing there. I set IsReadOnly="True" for the data grid.):

<data:DataGridTextColumn Binding="{Binding Quantity}" Header="Quantity" />

These are both unchanged from when I was binding to the mocked data. The code-behind had to change in order to bind to the different data source. Here's the binding code from the mocked data version:

        InitializeComponent(); 
        _industrialDetailsView = new PagedCollectionView((IEnumerable)IndustrialDetailsData.DataSource); 
        grid.ItemsSource = _industrialDetailsView;

And here's the binding code that uses RIA Services. Note that there is an IndustrialDetailsService on the server side from which the IndustrialDetailsContext is generated by RIA Services.

        _industrialDetailsContext = new IndustrialDetailsContext(); 
        _industrialDetailsContext.Load<IndustrialDetailDto>(_industrialDetailsContext.GetByFacilityAndAssessmentYearQuery(202, 2009), 
            loadOperation => 
            { 
                _industrialDetailsView = new PagedCollectionView(loadOperation.Entities); 
                grid.ItemsSource = _industrialDetailsView; 
            }, null);The data context for the details panel has not changed.  It is set from the data grid's SelectionChanged event handler like so:
            IndustrialDetailDto industrialDetails = (IndustrialDetailDto)grid.SelectedItem; 
            DetailsView.DataContext = industrialDetails;

Please let me know if there is other information that would be helpful.

A: 
MylesRip