Is there a "smart labeling" option in XamDataGrid that will turn underscores "_" into spaces and capitalize the first letter of each word?
ex. account_id to Account Id
I've seen this functionality with other 3rd party controls in the past, but not sure where it exists within XamDataGrid.
If not, is there a way I can intercept the population of each auto-generated field header's "onbound" event to inject my custom logic while conforming to the MVVM pattern?
Hello Patrick,
Thank you for your feedback.
I have been looking further into your issue and the current logic inside the FieldLayoutInitialized event is basically formatting the Labels for every Field, which is a View (MainWindow in our case) specific action. This way by keeping the code-behind View specific, you should be able to use the event handler and still keep the MVVM pattern and it's requirements.
Manipulating the Labels by using the ViewModel only would lead to the use of behaviors or commands, which will lead to some complications in the code, since this should be done for every Label and the ViewModel itself has no information in regards to what is visualized inside the View. For more detailed information on event handling in an MVVM WPF application, you can take a look at the following link:
http://social.technet.microsoft.com/wiki/contents/articles/18199.event-handling-in-an-mvvm-wpf-application.aspx
Another approach I can suggest you use is to create a Style targeting the LabelPresenter inside the XamDataGrid's Resources. Then you should be able to create an EventSetter for the Loaded event of every LabelPresenter and manipulate it's Content property in the same way as the Label of a Field.
Another approach you can use is to create a Converter in the View's code-behind, which converts the value for the Label property of every Field and returns the newly formatted string.
If you require any further assistance on the matter, please let me know.
Awesome thank you for the response! This solves my issue, but is there a way to tie into your XDG_FieldLayoutInitialized method using MVVM?
Thank you for choosing Infragistics.
I have been looking into your issue and I have prepared a sample application for you to test if the desired effect is achieved.
In regards to the labeling option you have described, please note that the XamDataGrid does not introduce a functionality of that kind by default. An approach I can suggest you use is to handle the FieldLayoutInitialized event of the XamDataGrid and to manually iterate through the Fields of the current FieldLayout. This way you should be able to use the ToTitleCase method of the TextInfo class in order to capitalize each word of the string and you can also use the Replace method of the String class in order to replace the underscore characters with a space.
You can also take a look at the LabelTextAlignment, LabelTextTrimming and LabelTextWrapping methods of the XamDataGrid's FieldSettings for any further manipulation over the Fields' Labels.
http://help.infragistics.com/Help/Doc/WPF/2016.1/CLR4.0/html/InfragisticsWPF4.DataPresenter.v16.1~Infragistics.Windows.DataPresenter.FieldSettings~LabelTextAlignment.html
http://help.infragistics.com/Help/Doc/WPF/2016.1/CLR4.0/html/InfragisticsWPF4.DataPresenter.v16.1~Infragistics.Windows.DataPresenter.FieldSettings~LabelTextTrimming.html
http://help.infragistics.com/Help/Doc/WPF/2016.1/CLR4.0/html/InfragisticsWPF4.DataPresenter.v16.1~Infragistics.Windows.DataPresenter.FieldSettings~LabelTextWrapping.html
If you require any further assistance on this matter, please do not hesitate to ask.