开发者

WPF App trouble adding new record

开发者 https://www.devze.com 2023-03-10 02:43 出处:网络
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 d

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!

0

精彩评论

暂无评论...
验证码 换一张
取 消