Is there a way to make the column headers of my data grid editable when a user double clicks the label? What I am trying to do is allow a user to create a customer header that will be more descriptive of the values in that column and bind part of the label to the value they added
I tried doing something like this with a page resource but that did not work:
<igDP:FieldSettings x:Key="Ems.Page.HeaderGroupFieldSettings" LabelTextAlignment="Center" CellContentAlignment="LabelOnly" CellClickAction="EnterEditModeIfAllowed" AllowEdit="True" AllowRecordFiltering="False" LabelClickAction="Nothing" />
Hi nwnerd,
That was simpler than I thought. The reason the header exits edit mode after one keystroke is because changing the Field.Label property causes a refresh in the XamTreeGrid where it didn't in the XamDataGrid. This refresh is causing the LabelPresenters to lose their editing state. The solution is to wait till you are done editing before updating the Field.Label property. You can do this by updating the Field.Label binding to use UpdateSourceTrigger=LostFocus.
I also moved the code-behind into an attached property in a different file so the code-behind is clean.
Let me know if you have any questions.
8712.EditableColumnHeaders.zip
Thank you!
You can definitely do this outside of code-behind. Usually this just means moving the code-behind into a Behavior<T> or creating an attached property that would be responsible for running the logic. I'll update the sample to remove the code behind.
As for getting editable columns working in the XamTreeGrid, i'll update the sample to a tree grid and see if I can reproduce that issue you are running into. Not sure why it would immediately end edit mode after one keystroke. Very weird.
I'll try to have something for you before the end of today.
Also, I was trying to get this to work in that sample project with a XamTreeGrid instead of the XamDataGrid & it exhibits some strange behavior. It builds & loads fine, & double clicking the header sends it into edit mode fine as well. But when you try to then edit the header, it only allows you one keystroke then it ends edit mode. Any chance to get this working with a XamTreeGrid? I'm actually fine with the code-behind at this point, but I really need it to work with a TreeGrid.
Is it possible to do this without code-behind? This behavior is exactly what I need, but I need it in an MVVM pattern with no code-behind.