validation - WPF Datagrid: Can't add row when the previous row is invalid -
i have view quantity (zero or more) of entity
objects loaded somewhere external (file, web service, etc). need user able edit loaded entities add new rows before saved in 1 transaction. @ time loaded, entities not valid; require user input before ready persisted. in order accomplish this, view contains wpf datagrid itemssource
bindinglist<entity>
, , entity
class implements idataerrorinfo
provide per-cell error messages displayed in tooltips in grid.
the default behavior datagrid when currently-selected cell has validation errors disable editing other rows adding new rows until issue resolved. not want; user should able takes make rows valid in whatever order he/she chooses. can make existing rows editable inheriting datagrid , overriding oncanexecutebeginedit
:
class editabledatagrid : datagrid { protected override void oncanexecutebeginedit(canexecuteroutedeventargs e) { e.canexecute = true; e.handled = true; } }
this works desired allow editing rows exist. still not enable adding new rows. there way override behavior? or need create custom "validation"-handling logic outside of wpf provides valid far framework concerned, avoid triggering unwanted limitations in provided controls?
update: behavior seems source of issue intermittently face datagrid. user able save work-in-progress , work on different "batch" of entities in meantime. in case, clear grid create fresh slate user. however, if datagrid has decided not create new placeholder row @ bottom due validation errors, there still no placeholder row when grid cleared, , user has no way continue. can try find override hack this, prefer fix underlying behavior (i.e. stop blocking adds/edits when current data "invalid").
Comments
Post a Comment