Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
260
XamDataGrid editable column headers
posted

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" />

Parents
  • 34510
    Verified Answer
    Offline posted

    Hi Adam,

    I have attached a sample that lets you double click on the XamDataGrid column headers and edit their text.  In the sample, I provided a ContentTemplate to the LabelPresenter which contained the text for the label along with a XamTextEditor which will be used to edit the text.  I then bound the LabelPresenter.Field.Label property to the XamTextEditor's Value property and I also bound the LabelPresenter.Tag property to the IsInEditMode property.  I also added an EventSetter to handle the MouseDoubleClick event.  Inside the event handler I set the LabelPresenter.Tag property to true.  This causes a DataTrigger to fire which shows the text editor and since the IsInEditMode is bound to the Tag property, it is placed into edit mode.  Once you have completed editing of the text and press the Enter key, this exits edit mode on the editor which sets the Tag property to false.  This then reverts the trigger so the editor is hidden.

    Let me know if you have any questions.

    EditableColumnHeaders.zip
Reply Children