I have a couple of UltraButtons on a wizard dialog that have been styled to be left or right arrows. This was pretty simple to do with the AppStylist, but now I'm having some trouble with the text. I'd like the text location to be centered on the button, but to have it ignore the arrow portion when determining the placement. See attachment for how it works now compared to how I'd want it to look. I could not find anything like this in the AppStylist settings, or any property I could set on the button definition itself to accomplish this. Am I missing something?
I'm pretty sure I could accomplish this with a UIElementCreationFilter, but I'd rather avoid that if I can - it can be pretty painful to make it right.
Hi,
So.. if I understand correctly, you are using an Image background (or possibly an image) to make the button look like an arrow. Is that right?
There's no way the control can take the image into account when aligning the text. It always aligns based on the bounds of the entire control.
So, I think the CreationFilter is the only way to go. You would just shift the TextUIElement over a little bit. I think you would have to hard-code the amount of shift, though, since there probably isn't any way to get the metrics from the arrow image.
I guess it would be nice if the control had a property for shifting the text - but there is no such property. There's a Margins property, of course, but I don't think that will work. It's a property on Control and if it works at all, I expect it would shift both the text and the image so that would not help.
Yep, the image is a background image. I was hoping there would be a property similar to ImageBackgroundStretchMargins that I set on the style (which defines the region of the image that will stretch). I'll look into the creation filter and see if I can tweak that. Will reply with results. Thanks!