"In the XamMultiColumnComboEditor, I want to stop the dropdown from resizing past the last column in the grid. I also want the dropdown to initially display the full width of the grid."
The XamMultiColumnComboEditor uses a Popup control for the drop down so you need to use this to find the column CellControls which will give you the widths you need. The only problem is that using the combo editor's DropDownOpened event won't give you the widths on the first try because the Columns haven't been created yet. This is where you need to handle the Popup's Opened event. This event occurs after the columns are created so we'll use it to traverse down the VisualTree of the popup and look for the first row in the grid. We then add up the widths of all the cells in that row and set the popup's width. At the same time we should set the Popup's MaxWidth to the same value so that resizing the dropdown won't let you go past the last column.
I've attached a sample that demonstrates the above method.
OK, I have been attempting to implment this sizing solution for a few days and I am having some issues. First off my multi-column comboeditor is displaying a header, and also the checkbox for marking multi-selected items from the list. What i find happening is that the call to VisualTreeHelper.GetChild(itemsPanel, i) as ComboCellControl, always returns null. What i found was that the first child of the panel is the header portion for the checkbox column and therefore cannot be cast into a ComboCellControl. What would be your suggestion as to how to tackle this? I am stumped.
Hi Joe,
I recommend taking a look at this forum post. It contains a sample that's basically an updated version of this thread's sample. It should help you handle that case where the header portion is the first child. http://es.infragistics.com/community/forums/t/73322.aspx
Rob,
Thank yo for the quick response, I had been reading that post as well as using the sample code to try to find a solution. I have made progress in that I can now size the drop list to display the columns wide enough to show all text. What I am finding frustrating is the first time into the event handler for popup_Opened, the DependecyObject returned by FindFirstRow doesn;t have any children and therefore skips the code to figure out the widths of each column. So what ends up happening is that my drop list is only as wide as the edit box portion of the control. Then when I close the drop list and reopen it, the list is sized appropriately. However, it may take 2 or 3 times to open and close the list before I get the width I expect. On the upside, once I get the width I want the list stays that size.
Any ideas?
I am using the Silverlight 5 controls, does that make a difference?
That may make a difference with some of the timing involved in my solution. Certain events need to be fired in a specific order for it to work on the first try. Let me convert this sample over to Silverlight to see what's going on.
You can reopen the panes after they have been closed as long as you know which pane you want. The XamDockManager has a FindPane method that you can use to find the pane, even when it is closed. It searches the ClosedPanes collection along with the other pane collections. You can then set the returned pane's Visibility property to Visibile and the pane will re-open. This should move it ouf of the closed pane collection into the open pane collection.
Thnks for the update and I will get this implmented ASAP. However, while I was waiting for your response I was working on another part of our application and it involves the XamDockManager. I am taking advantage of the DockManagers DocumentContentHost for displaying multiple tabbed documents. However I found that once I close all of the tabs contained in my TabGroupPane from the pane collection of the DocumentContentHost, that I cannot restore them. They end up in the ClosedPanes collection of the XamDockManager. So my next question would be can I move these panes from the ClosedPanes collection of XamDockManager to the Panes collection of the DocumentcontentHost and have them get displayed?
I know this is a new topic, but I wanted to continue moving forward while waiting. Thank for you help,
Joe
Well after a lot of playing around with it, the fact that controls aren't in the visual tree at the time they are loaded was a real set back, I think I've found a solution for this although it's a very hacky one. I don't know if there's a better way to do this but I ended up using the LayoutUpdated event as a psuedo-Loaded event since I know that when LayoutUpdated is hit the controls are in the visual tree. A couple of other changes were made as well with calculating the height of a row since initially the height the row would return was smaller than it actually ends up as. This was again because not all the cells were loaded.
I've attached an updated sample for Silverlight 5 using the 12.1 Infragistics assemblies. Let me know if you have any questions on this.
Good Morning Rob,
Thanks for the update, it is encouraging to hear that things operate adifferently in Sliverlight, I was starting to think I was going nuts. Like I said once everything gets rendered (I think) I am able set the width to what I want and it stays. I was going to try and navigate to each item in the list before trying to size it to see if that made a difference. I am curious as to what you come up with.
It looks like the timing between when controls trigger the Loaded event and when they are added to the visual tree is a bit different than in WPF. In my WPF sample by the time the Loaded event is called for the XamMultiColumnComboEditor, it's already in the visual tree. With Silverlight when the Loaded event fires, the control is still not in the visual tree so using this exact code for the Silverlight version won't work. I'll need to figure out a different way to handle this and make the appropriate modifications. Give me a couple of days and I should have something useable.