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
250
Is it possible to move the push pin icon to fix a header in a grid?
posted

I have a number of columns where i want to right align the column header text.

So i can right align the text but the icon for fixing the column still appears on the far right.

When i have my text right aligned i hwant to be able to left align the pushpin button.

Is this possible?

 

Thanks

Parents
No Data
Reply
  • 469350
    Suggested Answer
    Offline posted

    Hi Richard,

    There's no property for this, but it could be done using a CreationFilter. This is actually a pretty simple CreationFilter, since all you really have to do are swap the X values of the element rects.

    Here's a quick sample I threw together:


        public class FixedHeaderButtonOnLeft_CreationFilter : IUIElementCreationFilter
        {
            #region IUIElementCreationFilter Members

            void IUIElementCreationFilter.AfterCreateChildElements(UIElement parent)
            {
                // See if the parent is a HeaderUIElement
                HeaderUIElement headerElement = parent as HeaderUIElement;
                if (headerElement == null)
                    return;

                // Get the TextUIElement and the FixedHeaderIndicatorUIElement inside it.
                TextUIElement textElement = headerElement.GetDescendant(typeof(TextUIElement)) as TextUIElement;
                FixedHeaderIndicatorUIElement fixedHeaderIndicatorElement = headerElement.GetDescendant(typeof(FixedHeaderIndicatorUIElement)) as FixedHeaderIndicatorUIElement;           

                // If the FixedHeaderIndicatorUIElement is null, then do nothing.
                if (fixedHeaderIndicatorElement == null)
                    return;

                // Change the X position of the rect of the FixedHeaderIndicatorUIElement so it's
                // position on the far left of the header inside the borders.
                fixedHeaderIndicatorElement.Rect = new Rectangle(
                    parent.RectInsideBorders.X,
                    fixedHeaderIndicatorElement.Rect.Y,
                    fixedHeaderIndicatorElement.Rect.Width,
                    fixedHeaderIndicatorElement.Rect.Height);

                // Check to make sure there is a TextUIElement, just in case the header text is
                // empty.
                if (textElement != null)
                {
                    // Change the X of the TextUIElement's rect so that it is to the right of the
                    // FixedHeaderIndicatorUIElement.
                    textElement.Rect = new Rectangle(
                        fixedHeaderIndicatorElement.Rect.Right,
                        textElement.Rect.Y,
                        textElement.Rect.Width,
                        textElement.Rect.Height);
                }
            }

            bool IUIElementCreationFilter.BeforeCreateChildElements(UIElement parent)
            {
                // Do nothing
                return false;
            }

            #endregion
        }

Children
No Data