I've got a DataForm on a Silverlight 4 page. I bind it to the View on the class below. I am able to add, delete, edit, and move forward/back through records just fine using the controls built into the DataForm. But as soon as I remove the comment for the Filter or SortDescription, then every time I press the Add + button I get the dreaded "cannot change currency when an item has validation errors or it is being edited and AutoCommit is false" error. I've been stuck on this for hours and don't have a clue.
public class TestData {
OperationsDataContext context;
ICollectionView view;
public ICollectionView View { get { return view; } }
public IEditableCollectionView EditableView { get { return ((IEditableCollectionView)view); } }
public TestData() {
context = new OperationsDataContext();
context.Locations.Add(new Location { LocationId = 1, LocationName = "Home", CreatorUserId = 1 });
context.Locations.Add(new Location { LocationId = 2, LocationName = "Work", CreatorUserId = 1 });
context.Locations.Add(new Location { LocationId = 3, LocationName = "Office", CreatorUserId = 1 });
view = ((ICollectionViewFactory)context.Locations).CreateView();
// View.Filter = (o) => true;
// View.SortDescriptions.Add(new SortDescription("LocationName", ListSortDirection.Ascending));
}
}
I have attempted to add data manually using code - not the DataForm - and it works just fine even when both a filter and sort are specified.
TestData testData = new TestData();
Location item = testData.EditableView.AddNew() as Location;
testData.EditableView.CommitNew();
Why would it work from code but not via the DataForm? And why does the DataForm work when no filter is specified, but fail when a no-op filter that always returns true is specified?
may be you have similar issue as http://forums.silverlight.net/p/111217/250982.aspx post