I have a problem using a DrawFilter for a ComboBoxTool. The problem occurs when I use a ComboBoxTool within an UltraDropDownButton, but not within a Ribbon.
When I want to draw a text in the ComboBoxTool I use the GetPhaseToFilter method in the following way:
public DrawPhase GetPhasesToFilter(ref UIElementDrawParams drawParams) { if (drawParams.Element is EditorWithTextDisplayTextUIElement) { ComboBoxToolUIElement uiComboBox = drawParams.Element.GetAncestor(typeof(ComboBoxToolUIElement)) as ComboBoxToolUIElement; if (uiComboBox != null && uiComboBox.ToolbarsManager.Tools[uiComboBox.Tool.Key] is ComboBoxTool) { return DrawPhase.BeforeDrawForeground | DrawPhase.AfterDrawElement; } } return DrawPhase.None; }
When the ComboBoxTool is added to a Ribbon it works fine. But when the ComboBoxTool is added to an UltraDropDownButton it doesn't.
With the UIElements that come with the drawParams I'm not able to access the ComboBoxTool. But I need this to check the key and the ValueListItems.
Best regards.
Hello ,
Could you please clarify how exactly you have added ComboBoxTool into DropDownEditorButton, because DropDownEditorButton could accept only object derived from Control class and ComboBoxTool is not derived from Control class. So maybe there is something else in this scenario which you have missed. Is it possible to post simple sample that demonstrates your issue and we will be glad to investigate this further for you.
I am waiting for your feedback.
Thanks for your reply.
I've added the ComboBoxTool to an UltraDropDownButton, not to a DropDownEditorButton.
Attached a sample.
Thank you for the provided sample.
Instead of using drawParams.Element.GetAncestor(typeof(ComboBoxToolUIElement)), you should use drawParams.Element.GetContext(typeof(ToolBase)) as ToolBase, which will returns you corresponding TooBase element and you could get the key of this tool. I’ve modified your sample with this suggestion and now it works.
Please let me know if you have any further questions.
It works. Thanks for your help!