Forcing a visual tree repaint in WPF
So what does InvalidateVisual do? The SDK documentation says it "invalidates the rendering of the element, and forces a complete new layout pass. OnRender is called after the layout cycle is completed". Just what I needed when it was time to implement scrolling for a custom control shown below - or so I thought.

The custom horizontal scrollbar at the bottom of the control is bound to an ICommand whose implementation is shown below:
class ScrollCommand : BaseCommand
{
public ScrollCommand(Controller controller)
: base(controller)
{
}
public override void Execute(object parameter)
{
double value = (double)parameter;
controller.horScroll = value;
controller.designer.InvalidateVisual();
}
}
The Execute method will force the UIElements Field1, Field2 and Field3 to be repositioned in their respective canvas container relative to the value of the scrollbar by calling the host control's InvalidateVisual method. This provides the illusion of scrolling. It was a dud.
I was beginning to doubt this whole WPF Binding thing when I chanced upon the Measure method. The SDK describes this as "Updates the DesiredSize of a UIElement. Parent elements call this method from their own MeasureCore implementations to form a recursive layout update. Calling this method constitutes the first pass of a layout update in the layout engine". It looked very promising, so i replaced the call to InvalidateVisual with Measure as show below:
public override void Execute(object parameter)
{
double value = (double)parameter;
controller.horScroll = value;
controller.designer.Measure(new Size());
}
Needless to say it worked!