Hello,
I have a wingrid with the Header Text Wrapping set to True so I can have multi line headers. I have also set the HeaderAppearance TextValign = Bottom.
Can you please tell me the properties that would set the Valign of the Filter and Sort Icons to the bottom? They are currently aligned to middle and all properties I have tried have had no effect.
Thanks!
This works great. Thank You!
I am doing something very similar to this last post but also setting the width of the filter button to be wider. The problem that I have is that the button only highlights or will respond to clicks on the right of the button. This seems to correspond to the original size.
For example, the button will be 30 pixels wide but only clicking on the right 10 pixels shows the drop down. Furthermore, the border around the whole 30 pixels will show only when hovering over the right 10 pixels.
The code I have used is virtually the same as suggested (included below):-
Is there a way to get the button to respond normally at a larger width?
Thanks Simon
internal class FilterButtonCreationFilter : IUIElementCreationFilter { #region IUIElementCreationFilter Members
public void AfterCreateChildElements(UIElement parent) { if (parent is FilterDropDownButtonUIElement) { FilterDropDownButtonUIElement filter = (FilterDropDownButtonUIElement)parent; // Get Rectangle to render button as Size s = new Size(SharedSettings.DefaultControlWidth, SharedSettings.DefaultControlHeight); Point p = new Point(filter.Rect.X + filter.Rect.Width - s.Width, filter.Rect.Y); Rectangle rect = new Rectangle(p, s); // Render button bigger filter.Rect = rect; } else if (parent is SortIndicatorUIElement) { Size s = new Size(parent.Rect.Width, parent.Rect.Height); int left = parent.Parent.Rect.X + parent.Parent.Rect.Width - 60; Point p = new Point(left, parent.Rect.Y); parent.Rect = new Rectangle(p, s); } }
public bool BeforeCreateChildElements(UIElement parent) { bool retVal = false;
return retVal; }
#endregion }
Hi,
What's probably happening is that there is another UIElement (a TextUIElement would be my guess) that is a sibling of the FilterDropDownButtonUIElement. By enlarging the FilterDropDownButtonUIElement, you are causing those two elements to overlap and thus when you click on the left side of the FilterDropDownButtonUIElement, you are actually clicking on the TextUIElement, so the FilterDropDownButtonUIElement does not respond.
The solution is to move the TextUIElement - adjust it's width by the same amount you are adjusting the width and position of the FilterDropDownButtonUIElement so that they do not overlap.
You should probably be using the AfterCreateChildElement when the parent is the parent element of the FilterDropDownButtonUIElement rather than the FilterDropDownButtonUIElement itself. That way you can rearrange all of the children of that element. I assume it's the HeaderUIElement.
Let me know if you still need help getting it to work and I will whip up a sample for you.
Hi Mike,
Thank you very much - your suggestion was spot on.
I have managed to fix this now. For reference here is the code that I have used:-
public void AfterCreateChildElements(UIElement parent) { if (parent is HeaderUIElement) { // Resize Filter Button FilterDropDownButtonUIElement filter = parent .ChildElements .OfType<FilterDropDownButtonUIElement>() .FirstOrDefault();
if (filter != null) { // Get Rectangle to render button as Size s = new Size(SharedSettings.DefaultControlWidth, SharedSettings.DefaultControlHeight); Point p = new Point(filter.Rect.X + filter.Rect.Width - s.Width, filter.Rect.Y); Rectangle rect = new Rectangle(p, s); // Render button bigger filter.Rect = rect; }
// Move Sort Indicator SortIndicatorUIElement sorter = parent .ChildElements .OfType<SortIndicatorUIElement>() .FirstOrDefault();
if (sorter != null) { Size s = new Size(sorter.Rect.Width, sorter.Rect.Height); int left = sorter.Parent.Rect.X + sorter.Parent.Rect.Width - 60; Point p = new Point(left, sorter.Rect.Y); sorter.Rect = new Rectangle(p, s); }
// Resize Text box to stop obscuring the filter button TextUIElement text = parent .ChildElements .OfType<TextUIElement>() .FirstOrDefault();
if (text != null) { // If Size goes negative, this does not crash Size s = new Size(text.Rect.Width - 30, text.Rect.Height); Point p = new Point(text.Rect.X, text.Rect.Y); text.Rect = new Rectangle(p, s); } } }