I'v a wizard-style application that uses pages, and the user can navigate between them either using the Next or Previous button or using the navigation bar to directly access specific pages.
On one page (I will call it a โgridโ) I have a DataGrid binding to a DataTable. There is some source data in the DataTable, but with the help of the DataGrid the user can add, edit and delete rows at his discretion. On the next page (I will call the โcombo boxโ) there is a ComboBox that is bound to the same DataTable as the DataGrid on the grid page. Both pages use the same object as the data context.
If I go to the list page, then everything works fine, in the list box there is an entry for each row in the DataTable, as expected. Now go to the grid page and do not touch anything there, and then go back to the list page. ComboBox now displays a new item, NewItemPlaceholder. Obviously, this is because the DataGrid has UserCanAddRows set to true and thus displays a placeholder string for the new element. But this should concern only the DataGrid, and not the related DataTable, so in my eyes this is a mistake, or at least an absolutely terrible design.
Of course, I do not want the NewItemPlaceholder in my ComboBox (and choosing it caused a lot of problems). So how can I prevent it from appearing in ComboBox?
Update. In the meantime, I found that the placeholder is not in the DataTable as a string, which makes it even weirder if there is no flag in the DataTable that says: โThere is a NewItemPlaceholder in this table,โ but not the string itself. In addition, when I register in the ComboBox Initialized event, I have 2 elements that I look for, when I register the Loaded event, I also have a NewItemPlaceholder, so it should be added somewhere between these two events.
source share