I have to use some sort of dropdown/popup solution due to screen realestate of a tablet. One of the dropdowns needs to allow multiselection but by default all the selected values populate the textbox with a separator. Is there a way to override what the combobox displays so that it always displays a static string but only in multiselection mode?
Hello Mike,
Are you using the XamComboEditor that is WPF only or are you using the one that is Shared? The WPF only one has a Text property which you can use.
The Shared only one will require you to obtain the SpecializedTextBox and change the Text property based on how many items are selected. To obtain the Specialized textbox, use the following code: SpecializedTextBox STB = Utilities.GetDescendantFromName((DependencyObject)XamComboEditor1, "TextBoxPresenter") as SpecializedTextBox;
Also, here is a link to another forum post that had a similar issue to yours resolved: http://es.infragistics.com/community/forums/p/89755/443336.aspx
Please let me know if you have any other questions or concerns on this matter.
Sincerely,AndrewDeveloper Support IInfragistics Inc.www.infragistics.com/support
How do I tell which one I am using? I have a reference to InfragisticsWPF4.Controls.Editors.XamComboEditor.v14.1.dll so I assume it is the WPF only version. However, I ended up restyling it in order to be able to have rounded corners and change the background color so I might have pulled the shared version control template. I do not see any text property though. Is there a difference in functionality or performance between the 2 versions?
I am actually having one heck of a time doing anything non stock with this control. I feel like I have just about rewritten the whole thing. I need to be able to remove the horizontal scrollbar from the popup/dropdown and have the control resize to fit the string upon load to prevent the need for the horizontal scroll.
First of all, I apologize for the delay in my response, but I have attached a sample that I believe will solve this issue you are having.
The XamComboEditor that is in InfragisticsWPF4.Controls.Editors.XamComboEditor.v14.1.dll is the shared one. The WPF only one does not support multi-selection.
Regarding switching the text of the combo editor, you will need to obtain the SpecializedTextBox from the XamComboEditor and switch it based on how many items are selected. Also, for the XamComboEditor, you will want to set CustomValueEnteredAction to Allow or it will never let you set the static string in the Editor. Also, you will want to set AllowFiltering and AutoComplete to False, because it will not show anything in the editor after the string shows up if you don’t.
It is tempting to obtain the SpecializedTextBox and change the text property in the SelectionChanged event, but that also clears out your selection when the TextBox changes. What I did in my sample to get around this is I obtained the SpecializedTextBox in the XamComboEditor Loaded event, and then hooked up a TextChanged event to that TextBox. In the TextChanged handler, I check the XamComboEditor.SelectedItems.Count and change the SpecializedTextBox text accordingly.
Again, the sample project is attached to this message.
I made my XamComboEditor not editable. That seems to break your suggestion since that component is not visible. I tried working directly with the MultiSelectContentPanel and that works except when using checkboxes and unselecting one of the group. If I keep selecting then my custom code works but as soon as I deselect one (or more) and there is still at least one selected then it reverts back to using the concatenated list. Alomost as if there is another event that fires after the selection changed event. This is reproducible with your sample as well, just mark the comboeditor as IsEditable=false.
Thanks!
I have found a solution using the MultiSelectContentPanel StackPanel and the SelectionChanged event of the XamComboEditor. Directly after the if-statement that checks to see if the SelectedItems count is greater than 1, I placed a Dispatcher around the statements that clear out the StackPanel and add the TextBlock in as a child.
There must have been some other processes going on in the background when an item is deselected. This solution waits for those to finish, and then changes the StackPanel.
I have attached a sample project to demonstrate.
Just checking in, did you have any other questions or concerns on this matter?
Thanks. Your sample did help me figure out how to override the text after deselection.