Extending the Silverlight Custom Control

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.

Lookup Prefilters

A question came up on to how to use PreFilters on a dependency lookup to provide != functionality. No matter what was set as a conditional operator it seemed like it would return the list based on the condition ‘=’. The prefilters will work as long as as the operator was in the validation list. The following operators are allowed in dependency lookups. Note that the names are case sensitive when typing them in.

  • Starting with
  • Contains
  • Equal to
  • Not Equal to
  • Greater than
  • Greater than or Equal
  • Less than
  • Less than or Equal

with that in place the following code will work correctly in a Smart Part load action


Sage.SalesLogix.HighLevelTypes.LookupPreFilter filter
    = new Sage.SalesLogix.HighLevelTypes.LookupPreFilter("Area", "Area 1");
filter.CondOperator = "Not Equal to";

Building a Custom Control For SalesLogix Web

I believe it is well know my affection for Silverlight and the development experience it provides. The biggest problem with Silverlight in SalesLogix is that whenever you want to host a application you needed to create a custom smartpart and work outside of the box. For some time I have been mentioning to the core dev team at Sage that they should enable a design time experience to allow for easier embedding of a SilverLight control.

So this morning when I got in the office I decided to roll up my sleeves and roll out a host control.

Building the control

1. Create a new .Net Assembly

2. Add References to core SalesLogix assemblies


You will find this assemblies in the SalesLogix\Platform folder

3. Create a class that derives from


4. Add custom control properties


5. Compile and copy the resultant assembly to the Programs\SalesLogix\ folder

6. Register your assembly with the control assembly list

This is nothing more then adding a entry into the QuickFormsConfiguration.xml file. Though I think from an upgrade process or multi-system process this is problematic it does work well. The Help file gives details to the location of the file for different systems. Within my system I navigated to C:\ProgramData\Sage\Platform\Configuration\Application\SalesLogix

7. Create a new Code generation template (velocity)

This was fairly simple to do. I copied an existing template file and renamed to SilverLightHostControl.WebControlRenderingTemplate.vm . Opening the file and deleting the contents to have an empty and ready to copy in the basic Silverlight control rendering code. Once completed adding the code I saved the file. I also copied the file to my control solution so that there was a ready backup provided for me if the system lost the original.

8. Add the control binding into the into the Control list

The final step was to add the control details to the Web.ControlConfiguration.xml file. This file is located in the model and contains the details for the controls that will be available for the smartpart designer.  I added a new WebControlRenderingProvider node. I found it easiest to copy an existing node and replace it with the my control specific details.


9. Test

Once all the steps were completed it was time to test the control and ensure that the contents rendered correctly. Starting architect and I located a page to host the Silverlight control. Easily located in the add control menu.




Finally compiling the site and deploying resulted in the following output.



Final comments

Adding custom controls is an interesting and powerful way of adding new features to your site and can open up functionality that is not quite possible otherwise. The biggest caveat is the number of files that need to be altered to get this to work just right and how that would be managed in a team based project. With the right processes however it can enable some really exciting features.