WPF App trouble adding new record
I know that I'm missing something.
Right now I am creating a very simple WPF app and I am simply trying to add a new record through a Window with many textboxes and Datepickers on a Grid. Through debugging I can tell that the record is being added, but the UI does not change/update, sticking on the same record, giving me no opportunity to populate the rew records' fields. What results is that it cannot save because I have a field that is not nullable. I am thinking I need to update the claimInventoryViewSource which is the DataContext of the main grid, but I have no idea how to do that.
Here is my code right now:
//Create a new claim
var newClaim = new Claim();
newClaim.DateCreated = DateTi开发者_StackOverflowme.Today;
_context.AddToClaims(newClaim);
_claims.Add(newClaim);
This seems to work, but what am I missing is the line to have the UI update to the new record?
I figured it out! I added these lines of code and had to tweak some things in the XAML, but I got it to work.
private CollectionViewSource _claimViewSource;
...
_context.Claims.AddObject(new Claim());
_claimViewSource.View.Refresh();
_claimViewSource.View.MoveCurrentToLast();
Thank you for your assistance!
精彩评论