I have reviewed previous posts regarding removal/modification of the SortIndicator from the Column Header LabelPresenter. So far the solution seems to be centered around creating a custom control template for the LabelPresenter, however I'm hoping there is a grid-wide way for me simply collapse the existing SortIndicator area without having to recreate and hard-code all the entire IG LabelPresenter styling in my app.
Do any IG Grid / Styling gurus have any idea on how I can accomplish this?
IMHO: That dedicated SortIndicator space REALLY messes up visual alignment of column headers and makes for an overall unprofessional look :( I understand why it exists - and it's great to have the feature, but the grid would be so much better if we could collapse it when column sorting is not required - which in my case is almost always.
Thanks in advance for any help you can offer.
I have a question about xamDataGrid, I have a percentage column, I want to sort it, but it's string type instead of number, so sometimes it sort wrong, do you have a better solution?
I try to sort it by data table, then bind to the user control, but I don't want to use the default sort function, and I want the triangle character display correctly, how can I do, thanks very much.
Hi Alex,
Can you please tell me how to remove SortIndicator with default styles or in xaml, if possible example?
Thannks,
Abhinav
Alex: You ROCK!
Your solution worked perfectly. Thank you so much.
For others who may use this, you'll need to reference the following namespaces in your code behind:
Infragistics.Windows.DataPresenter (for LabelPresenter)
Infragistics.Windows.Controls (for SortIndicator)
At your service,
Jeff
The SortIndicator is used to display a notification that this field is sorted. If you want to remove it and use this space, you have to either create a new control template or remove it from the existing one. I believe you know how to do this using the Default Styles, so I am pasting code that will collapse the sort indicator from procedural code:
void xamDataGrid1_Loaded(object sender, RoutedEventArgs e)
{
// Get LabelPresenter
LabelPresenter lp = Infragistics.Windows.Utilities.GetDescendantFromType(xamDataGrid1,
typeof(LabelPresenter),
false) as LabelPresenter;
if (lp == null)
return;
// Get the Parent
DependencyObject parent = lp.Parent;
int count = VisualTreeHelper.GetChildrenCount(parent);
// Get all of the LabelPresenter and their Sort Indicators and collapse them
for (int i = 0; i < count; i++)
DependencyObject child = VisualTreeHelper.GetChild(parent, i);
SortIndicator si = Infragistics.Windows.Utilities.GetDescendantFromName(child,"SortIndicator") as SortIndicator;
si.Visibility = Visibility.Collapsed;
Debug.WriteLine(child.ToString());
}