Hi,
I want to have something similar to the UltraTextEditor->ButtonRight propertey.
But instead of a button I want to have an additional TextUIElement, so I tried to write my own via CreationFilter. But why is the TextUIElement dissapearing if I enter the edit mode.
The creation filter code:
public class AddLabelCreationFilter : IUIElementCreationFilter { public void AfterCreateChildElements(UIElement parent) { if (parent is EditorWithTextUIElement) { EditorWithTextUIElement editorUIElement = parent as EditorWithTextUIElement; TextUIElement txtElem = new TextUIElement(parent, "AB");
int xPos = editorUIElement.Rect.Width - 40;
txtElem.Rect = new Rectangle(xPos, 1, 40, editorUIElement.Rect.Height);
UIElement dispElem = editorUIElement.ChildElements.FirstOrDefault(x => x is EditorWithTextDisplayTextUIElement);
if (dispElem != null) { dispElem.Rect = new Rectangle(dispElem.Rect.X, dispElem.Rect.Y, dispElem.Rect.Width - 40, dispElem.Rect.Height); }
editorUIElement.ChildElements.Add(txtElem); } }
public bool BeforeCreateChildElements(UIElement parent) { return false; }
}
Hi Michael,
Thank you for posting in our forums.
The reason why your additional text element disappears when you enter edit mode is because the control displays a Microsoft TextBox control over its edit area when in edit mode. This TextBox is what hides your TextElement and it will always occupy the whole edit area. What I suggest to do in order to resolve this, is to add a button to the ButtonsRight collection of the editor and then to use its rectangle for the text element. You can hide the Button by using a DrawFilter to skip its drawing.
I have attached a sample which demonstrates this suggestion.
Please let me know if you have any additional questions.