Balloon background

I have a sideways stop light image that I am hoping to make the background of a goBalloon. The background property says it only “gets” the background. Is there an example I can look at of setting the background of a balloon to an image? or is that even possible?
Thanks, Mark

You can set the GoBalloon.Background property, but GoBalloon assumes the Background object is a GoPolygon, so that it can shape it appropriately, so you won’t have the “balloon” appearance that “points” at the Anchor object.
If you want to display an image within the balloon shape, I suppose you could subclass GoPolygon and override Paint to draw the image you want with the bounds you want. Then you can either set the GoBalloon.Background property to an instance of your new polygon class, or you can override GoBalloon.CreateBackground so you don’t have to worry about such initialization in all the places you might be creating a GoBalloon.

I want to do something similiar, but wanted to discuss the two ways I’ve been considering, to get an idea if anyone would think one or the other is easier:

I want to make a GoBalloon with no text–just an dynamically sized image i as the rectangular part. The image is always rectangular in appearance.

Method 1:
Assign Background a new GoObject which is really two parts. One is the image itself, and the other is a GoPolygon to create the balloon pointer (a triangle) from the anchor point to the edges of one side of the image. So procedurally, I would first create the image. Then knowing location of image and location of anchor point, I should be able to draw the triangle from anchor to side of image.

Method 2:
Don’t override GoBalloon at all. First generate dynamic image so I know size of the image. Generate enough whitespace text to make the GoBalloon the right size to hold the image (since GoBalloon doesn’t support resize: goballoon).
Finally, put GoImage directly to the view in the right spot in the GoBallon’s rectangle. Personally I’m not too clear on how I’d know exactly where the rectangular chunk of the GoBalloon is, but I guess I could look at the .Background as a GoPolygon and reverse-engineer the coordinates to figure out which apply to the rectangle.

Any first thoughts on which would be the better way to go?

How about this: add a GoImage to the GoBalloon, and modify the Label (a GoText) so that it does not automatically resize itself as the text string is changed. Override LayoutChildren so that the size of the Label is always the same as the Size of the Image.
public class ImageBalloon : GoBalloon {
public ImageBalloon() {
this.Label.AutoResizes = false;
this.Label.Wrapping = true;
this.Label.StringTrimming = StringTrimming.EllipsisCharacter;
this.Label.Clipping = true;
this.Label.Editable = false;
this.Label.Size = new SizeF(100, 100);
GoImage img = new GoImage();
img.Selectable = false;
InsertBefore(this.Label, img);
public GoImage Image {
get {
if (this.Count < 2) return null;
return this[1] as GoImage;
public override void LayoutChildren(GoObject childchanged) {
GoImage img = this.Image;
if (img != null && img == childchanged && this.Label != null) {
this.Label.Bounds = img.Bounds;
You can modify the image at any time by modifying the GoImage that is the value of the Image property.
Note that you can still display text on top of the image, just by setting the Text property. I have set the Label properties in the constructor so that this option will work reasonably, if you choose to use this possibility. Actually, if you did not need to display any text, it would be simpler to just set .Label.Visible = false instead of setting all of those Label properties.

Very nice. I didn’t realize this was even possible.

I’ll let you know how it goes! Thanks Walter!

Took me all of 10 seconds to apply your code with a static image. Now I just need to do my dynamic image creation code and I’m good to go.

Thanks alot Walter…