Earlier today I posted about creating a custom control to Host Silverlight content inside of SalesLogix. The design time experience was less then desirable as the it looked like an unbound stock control. I really wanted it to stand out from the other controls so I decided to look in to how to control the rendered UI in the quick form editor.

The great thing is its pretty easy to do and in a matter of minutes I was able to get a look and feel that was different then the default.


As you can see from the image the control does not look anything like the standard bound control and makes it easier to call out on a given smart part.

So how did i do this. Easy override the Draw method and paint the region the way I want. The following is the code I used to pant the area.

public override void Draw(System.Drawing.Graphics graphics, System.Drawing.Rectangle clientRectangle)

           using (SolidBrush backgroundBrush = new SolidBrush(Color.FromArgb(0xFF, 0xFF, 0x99)))
               graphics.FillRectangle(backgroundBrush, clientRectangle);
               using (SolidBrush foregroundBrush = new SolidBrush(Color.Black))
                   using (Font labelFont = new Font("Arial", 10))

                       string caption = "SilverLight [" + XapName + "]";
                       var stringSize = graphics.MeasureString(caption, labelFont);

                           new Point(
                               clientRectangle.Left + ((int)(clientRectangle.Width – stringSize.Width) / 2),
                               clientRectangle.Top + ((int)(clientRectangle.Height – stringSize.Height) / 2))

Hope this helps you create your own controls that are distinctly different.

Leave a Reply