Hello,
I am trying to put text to be horizontal in UltraCheckEditor (button style), but i cannot get CheckEditorImageAndTextButtonUIElement, so i can set Multiline property. Can you just tell me what's missing in my code.
public class MultiLineCheckEditorCreationFilter : IUIElementCreationFilter { #region IUIElementCreationFilter Members void IUIElementCreationFilter.AfterCreateChildElements(UIElement parent) { UltraCheckControlUIElement element = parent as UltraCheckControlUIElement; if (element != null) { EmbeddableCheckUIElement check = element.ChildElements[0 as EmbeddableCheckUIElement ];
/// This is where i stopped, check has no ChildElements when you cast it. CheckEditorImageAndTextButtonUIElement textUIElement = check as CheckEditorImageAndTextButtonUIElement; if (textUIElement != null) { textUIElement.MultiLine = true; } } } bool IUIElementCreationFilter.BeforeCreateChildElements(UIElement parent) { // Do nothing. return false; }
Thanks,
Ivan
Hi Ivan,
Sorry... I could have sworn I tested with Button style, but I was trying out different things and I must have gotten mixed up. You are right, this will not work for Button style. The UIElement are different for a button, and it looks like in Button style, you need to use the CheckEditorImageAndTextButtonUIElement.Your original code isn't working because you are walking down the element chain into the child elements and there is no need to do that because the CreationFiliter fires for each element. You are getting the main control and then trying to get a descendant element before that element has been created. But you don't need to get that complicated.
class MultiLineCheckEditorCreationFilter : IUIElementCreationFilter { public void AfterCreateChildElements(UIElement parent) { var textUIElement = parent as CheckEditorImageAndTextButtonUIElement; if (null != textUIElement) { textUIElement.MultiLine = true; } } public bool BeforeCreateChildElements(UIElement parent) { return false; } }
Hi Mike,
I didn't write in this forum for a few years, but you are still here
Yes, sorry i didn't explain better, yes, you are right, i need this text
V
I
D
E
O
ultraCheckEditor1.Text = "V" + Environment.NewLine + "I" + Environment.NewLine + "D" + Environment.NewLine + "E" + Environment.NewLine + "O";
I already tried this code, i found it in some previous post, and it's working if Style of editor is CHECK, but problem is when Style of editor is BUTTON. This code is not working there. So what to do when style is Button???
I'm confused. What are you trying to achieve here? UltraCheckEditor already displays the text horizontally (in every style) and already wraps the text to multiple lines if it does fit. So I'm guessing that you want to set the text to something with NewLines in it so you can control where the wrapping occurs? If that's what you want, you can do this:
class MultiLineCheckEditorCreationFilter : IUIElementCreationFilter { public void AfterCreateChildElements(UIElement parent) { var textUIElementBase = parent as TextUIElementBase; if (null != textUIElementBase) { textUIElementBase.MultiLine = true; } } public bool BeforeCreateChildElements(UIElement parent) { return false; } }