Controller.RenderEngine.Content – what does it give us access to?

After a dry spell, there’s now a couple of posts at once… 🙂

I have alluded to this in the past, but I thought I’d take the opportunity to provide a specific post on this topic.

The name itself is a little misleading, but…

To answer the question, it gives us access to the VisualTree, a tree that we can iterate up and down to our hearts content. How do I know this? A number of years ago I was working on a coolstorage program where I needed to explore the visual tree to provide some nifty effects. It was there that I learnt about WPF and how the interface objects were stored as a hierarchy and I gained a newfound respect for Microsoft and WPF!

Why am I going on about this – well, ScriptUtil.FindChild() will only go down the visual tree, not up it, so it is very helpful for us to know where in the scheme of things Smart Office grants us an entry point – then we will take that entry point and exploit the .Net framework 🙂

Probably the easiest way to demonstrate where the Controller.RenderEngine.Content sits in the visualtree is with a script:

import System;
import System.Windows;
import System.Windows.Controls;
import MForms;

package MForms.JScript
	class testContent
		public function Init(element: Object, args: Object, controller : Object, debug : Object)
			 var content : Object = controller.RenderEngine.Content;
			 content.Background = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.Black);



This script will simply set the background to black for the area that the .Content grid occupies. Nice, quick and easy.

As we can see the Sorting order isn’t within the black area, so passing controller.RenderEngine.Content to ScriptUtil.FindChild() will just return null. We have to walk up the tree to get to the sorting order.

This can be done with some code like so – this will take you all the way up the visual tree (I usually look for a standard control and iterate up the list until I hit that control).

var parent : Object = content
var lastParent : Object = content;

while(null != (parent = VisualTreeHelper.GetParent(parent)))
	lastParent = parent;



This entry was posted in Uncategorized. Bookmark the permalink.

2 Responses to Controller.RenderEngine.Content – what does it give us access to?

  1. engmero says:

    please can you write a full script to coloring sorting order level

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s