Good morning,
I just started with the Infragistics WPF suite. While I use the Infragistics Windows Forms suite for quite a while now I stepped into a problem.
Here's the case:I have a BindingList containing objects, nothing special.That BindingList is bound to a xamDataPresenter using an ObjectDataProvider in XAML.
So far so good, records get displayed as expected.
Not there is a "remove" button that should remove a selected row.How can I do this in code?I already tried:
DataPresenterCommands
.DeleteSelectedDataRecords.Execute(null, dpOverview);dpOverview.UpdateLayout();
...which does nothing, I casted the DataSource to a BindingList of correct type and removed the record there, not visible and even if I delete the item from the database I am not able to remove the corresponding row.
How can this be done in code? Any hints are kindly appreciated.
best regardsAndy
...a little update:
I figured out why the DeleteSelectedDataRecords command didn't work. I set AllowDelete to true and now it works.
Unfortunately there is now a little popup asking me if it is "ok" to delete the selected records.Actually I do not wan't to ask the users if it is ok for them, I just assume it is. So can this message be suppressed?
I am wondering if this is the correct approach for this scenario. Is there a better way to remove records?And how do I get rid of the popup ;)
Another Update.
I played a round with this problem. When creating a BindingList object in code and then bind it to the datapresenter I can use a reference (private field) of this to remove items via this.queue.RemoveAt(0) for example.
But I am interested in doing this in XAML using Binding.
An other interesting thing is that the datapresenters DataItems are always empty... I assumed when setting the DataSource with Binding it should return a collection to add records etc.
So finally here are the open questions regarding this, I would very much appreciate if somebody could answer them:
- how can I remove rows from datapresenter- how can I remsuppress the popup- why is the DataItems collection always empty- is there a better approach for this... removing records
Binding should still be done with XAML.
Thanks in advance,best regardsAndy