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
405
Remove and Recover SortIndicator space from LabelPresenter Area
posted

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.

Parents
No Data
Reply
  • 69686
    Verified Answer
    posted

    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());

                }

            }

Children