Does anyone know what is the easiest way to get from an EditorButton object to the associated EditorButtonUIElement?
I don't think you can get the UIElement from a single button instance. The button object may be represented by more than one UIElement. If the button is in a grid cell, for example, it will show up with a different UIElement in each cell.
If you are just using the editor control, where there is only a single instance, then you could get the element from the control using control.UIElement.GetDescendant and passing in the button as context.
But this seems like a really odd thing to do. You cannot modify the UIElement in this way... so why are you trying to get it? What are you trying to do?
A little background...we use the IDataErrorInfo pattern to relay business object error information to our users. One of our major UI elements used throughout our application is a custom editor that inherits from EditorWithText.
The custom editor has an internal error state that we need to pass along to the user. For consistency sake, our UI designers would like to simulate the IDataErrorInfo behavior (error icon within the editors UI space)...complete with a tool tip message giving details about the error.
Since the error is fully contained within the editor, I cannot take advantage of the normal IDataErrorInfo implementation our application uses.
In an attempt to satisfy the UI requirement, I want to use a flat borderless EditorButton to display the error icon within the editor. My issue is that I need a way to connect the tool tip text that provides the detail of the error to the EditorButtonUIElement that is displaying the error icon.
I would like to design this in a way that can be used for other places that we need tool tips...so instead of inventing my own complicated plumbing that generalizes this behavior across lots of different types of UIElements, I was hoping to leverage the ToolTipItem property of the EditorButtonUIElement.
If I could set the ToolTipItem property when the EditorButton was created, it would be really easy to get the tool tip displayed when the mouse enters the element.
I realize that Cell and MergedCell are the only grid objects that natively take advantage of the ToolTipItem to display the tool tip (working in 8.2), but I would like to put code in MouseEnterElement could use the UIElement directly to display the tool tip. In the future, if the grid started to use the ToolTipItem more generally across different types of UIElement objects, I would be prepared to take advantage of it...and would only need to add exclusions to my custom tool tip display code in MouseEnterElement.
Thoughts?