I have a XamDataGrid which is bound to an entity (entity framework) through a BindingList. The grid contains the basic columns from the entity. If I edit the fields on the grid, the grid displays a nice edited icon. My question is how can I show that edit icon if the entity is modified outside of the grid?
For clarification, the grid allows the users to edit only the basic fields from an entity. There is a more detailed editor underneath the grid that allows users to edit more information about the entity. If the user edits the information in the detailed editor, it updates the entity but doesn’t show the edited icon.
Hello chinupson,
Thank you for your post. I have been looking through it and I assume you bind your additional editor textboxes directly to the DataSource and the update doesn’t go through the XamDataGrid and this is why you don’t get the update icon. I attached a sample project with both ways of binding, so you can see the difference. In order to get the update icon the textbox should be bound to the XamDataGrid’s Cell. Please let me know if this meets all your requirements or you need any further clarifications on this matter.
Looking forward for your reply.
Thank you for your help, I didn't know you could easily bind to a active record. The one draw back to this is that I would have to setup lots of hidden columns in the grid. I was hoping there was a way I could directly control the icon.
Thanks again Stefan, I will do that.
Hello again,
If you have too much fields to define you can simply set AutogenerateFileds to True in Xaml and in the FieldLayoutInitialized event of the XamDataGrid you can check if the field name is some of the ones that you don’t want to show and set its visibility to collapsed. Here is the code for the sample I previously attached:
foreach (Field item in xamDataGrid1.FieldLayouts[0].Fields) { if ((item.Name != "Name") && (item.Name != "Age")) { item.Visibility = System.Windows.Visibility.Collapsed; } }
Please let me know if this meets all your requirements or you need further assistance.