Hello,
I followed your solution on this link to apply a string format on the Header of the column in the RadGridView:
https://www.telerik.com/forums/stringformat-not-working-for-gridviewdatacolumn-header
With this solution, if the bound property has a value "test", in the TextBlock.Text inside the header I will show "test 123" ("123" came from the StringFormat).
This solution works but I face a bug when I use it with another functionality. I have implemented a button that on click opens a ListBox on a ContextMenu to show/hide the RadGridViewColumns). See the following link:
https://www.telerik.com/forums/add-button-to-radgridview-column-header
The RadGridView.Columns are bound to the ListBox.
The ListBoxItem.Template has a Checkbox where the IsChecked property is bound to the Column visibility state and the Content property is bound to the Column header.
If the Listbox is shown (by click on a button, the ListBox is displayed on a ContextMenu), the Header template is dissapeared from the GridViewDataColumn.Header and it is shown on the ListBoxItem. It likes the template is "moved".
If I put the DataTemplate on a resource with x:Shared=False then it still dissapears from the header and it appears twice on the ListBoxItem.
Note:
1. I tried to use the Header without a DataTemplate but I can't use a converter to append the "123" because I already have one converter that can't have other functionality.
2. My current workaround is to do the converter code and the text append on the code behind of the xaml. Then I can bind the xaml.cs String property to the GridViewDataColumn.Header and remove the DataTemplate. The problem with this solution is that I need to do this on each xaml, and cannot be set on a style. In addition, I don't want to use code behind at all.
3. Any workaround without using the DataTemplate will work for me. I can "live" with that problem if you help me solving this specific case because I usually don't use DataTemplates on headers at all.
4. If you can look at your code, I would appreciate if you can think how the DataTemplate is dissapeared. I think that you have a bug somewhere because a Binding should not remove a Template from your control.
The bug is the same as described in this post (screenshot attached)
https://www.telerik.com/forums/gridview-columns-headers-disappearing-after-binding-to-controlpanel
I need a workaround to display the complete text without DataTemplate, because the solution here of adding DataTemplate for all columns of the application is not aceptable. Maybe there is a way to trigger the Context on the ListBoxItem and changed the binding according to the content type?
Thank you,
Alex.