Hi,
I am trying to come up with a solution for a datagrid, that has a combobox in one of the columns, allowing to select value for a new record. At the same time, record in the grid (existing record) should not allow having a drop down open in the same column.
Can someone come up with an example implementation for MVVM?
Thanks.
PS: I am using v 12.1 for this project
Hello Ilya,
Thank you for your post!
I have been looking into it and it seems, that I am missing something for your scenario. Currently when the user opens a drop down, in order to add a new record, he/she can open a drop down in an already existing record. When a drop down in an existing record is opened the one in the new record closes.
Would you please provide me with more detailed information about the functionality you want to achieve? Should drop downs in the already existing records be disabled while the user adds the new records?
Thank you for the provided information. Looking forward to hearing from you.
Actually, the drop down should only be enabled in the "Add record" section. The existing cell should be read-only. So, the cell type can be a 'TextBlock" or something similar, where as the type of the "Add Record" is a combobox.
Thanks,
Ilya
Thank you for the provided information.
I have been further researching your issue and have created a small sample application for you. In the sample application I have a simple XamDataGrid and one of its Fields has XamComboEditor.
In order for the combo to be disabled when the user adds a new record I have created a style for the DataRecordPresenter, with a Trigger, that checks if the "IsAddRecord" is true or false.
The "IsAddRecord" indicates if the record is the one, that the user uses to add new records or already existing one. If the mentioned property is true I set the IsEnabled property of the DataRecordPresenter to true.
In order this style to apply only when the user adds a new record I am handling the EditModeStarting event. In the handler of the event I am checking if the user edits the AddNewRecord or an existing record. Then in order for the user to be able to edit the rest of the Fields when he already added the new record I have handled the EditModeEnding event and remove the style in the handler of this event.
Please find the attached sample application and feel free to let me know if you have any further questions on this matter.
Provided example does not work.