Hello,
I've succesfully added buttons in the header of a UltraExpandableGroupBox with a creation filter, using the example on this site. However, now I need to have a track bar in the header. This doesn't seem to work as expected. When I add it, I can see the track bar in the header, but it doesn't repaint when I change it's value. When I drag the entire form out of the screen and back, I can see the value has actually changed.
I've tried all kinds of solutions. Refreshing / invalidating the trackbar, the element, etc. Can someone help me make this work? I would like to use the creation filter, because I already use it for adding buttons in my original project. Below is some sample code. Create an application "GroupBoxWithTrackBar" and add an UltraExpandableGroupBox to the form. Then override Form1.cs with the code below. I'm using version 10.3.20103.2145. Thanks in advance.
using System; using System.Windows.Forms; using Infragistics.Win; using Infragistics.Win.Misc; using Infragistics.Win.UltraWinEditors; namespace GroupBoxWithTrackBar { public partial class Form1 : Form { public Form1() { InitializeComponent(); } protected override void OnLoad(EventArgs e) { base.OnLoad(e); ultraExpandableGroupBox1.CreationFilter = new TrackBarCreationFilter(); } } public class TrackBarCreationFilter : IUIElementCreationFilter { private readonly UltraTrackBar TrackBar; public TrackBarCreationFilter() { TrackBar = new UltraTrackBar(); } #region IUIElementCreationFilter Members public void AfterCreateChildElements(UIElement parent) { if (!(parent is GroupBoxHeaderUIElement)) return; var rect = parent.Rect; rect.X += rect.Width - 100; rect.Width = 90; TrackBar.UIElement.Rect = rect; parent.ChildElements.Add(TrackBar.UIElement); } public bool BeforeCreateChildElements(UIElement parent) { return false; } #endregion } }
After deep investigation of this issue, the only way which I found in order to achieve your goal is to configure your own composite control which behalves a UltraExpandableGroupBox. I’ve implemented this in a simple demonstrative sample, please see attached sample. There is some odd issue with the designer wit this approach, but it is only in design time.
I hope that this will helps you.
Thanks for sorting this out. I would like to use the approach of placing an UltraTrackBar control in the group box itself. However, now I face two problems.
1. Because the Track Bar is a child of UltraExpandableGroupBox, determing the location is problematic because I need the location relative to GroupBoxHeaderUIElement. Maybe I could try something with PointToScreen and PointToClient, but UIElements don't support that.
2. If I want to position the track bar on the header, it will actually be placed outside the UltraExpandableGroupBoxPanel and won't get drawn.
Or maybe I misunderstood your suggestion. In that case, could you point me in the right direction, perhaps with some sample code? Please bear in mind that in our original project, we create UltraExpandableGroupBoxes in code on the fly. So I would prefer not to add track bars to the parents of group boxes, unless we can control everything from within the group box or creation filter. Thanks!
Hi,
Yeah, there's enough info here for me to go on, so I tried it out and I get the same results you do.
I tried updating the Value of the Trackbar in code and it doesn't update. I haven't been able to track down why. But I don't think it matters, because clearly the much more important issue is to get the trackbar to respond to the mouse - otherwise, it will be pretty useless. And as far as that goes, this isn't going to work because the Control element isn't expecting to be a child of another element.
The Button element is different, because it's just a regular UIElement that is designed to work inside another element. But TrackBar.UIElement is a ControlElement and this is not designed to be embedded inside another element. I think the main reason the mouse doesn't work is that the UltraTrackBarUIElement expects to be directly in an UltraTrackBar control and it's using the control's rect to filter out mouse messages. In this case, your UltraTrackBar control exists nowhere on the screen, so no mouse messages will ever hit it.
You could probably get this to work by using the TrackBarEmbeddableUIElement, which is the element inside the UltraTrackBarUIElement which doe all the real work. But even this would be very difficult because it would require an editor owner which you would have to create and implement yourself and it's not a trivial undertaking.
Frankly, it would be a LOT simpler just to place the UltraTrackBar control into the ultraGroupBox itself. If you are concerned about positioning it correct in relation to your buttons, then use the CreationFilter. Create your own class that derives from UIElement (let's call it TrackBarContainer UIElement). Override PositionChildElement on that element an in that method, position the UltraTrackBar control over the element.
The code in my opening post should demonstrate the problem (dragging or clicking on the track bar does not seem to work, but when it does get repainted, the value was actually changed).
Or do you want me to add my attempts for refreshing / invalidating the UI element?
Well, buttons are a little simpler than a trackbar.
But if you can post a small sample project demonstrating what you have so far, I would be happy to take a look at it and see if I can figure out why it's not working.