I’ve seen a few forum posts about providing a richer expression editing experience in a rehosted workflow designer. There are two main scenarios in which you would want to implement your own expression editor:
Our intrepid expression editor tester, Eric Wong, put together a small app that demonstrates the process of implementing a custom expression editor. There are three basic steps:
Eric’s app has two projects, a class library that implements the editor service and instance and a WPF application that rehosts the designer and publishes the service. The class library is a proof of concept, and doesn’t do anything terribly interesting (you’ll have to roll your own IntelliSense). The most important part of the example is the code that he uses to publish the service, called MyEditorService. Here it is:
public void createDesigner() { WorkflowDesigner designer = new WorkflowDesigner(); Sequence root = new Sequence() { Activities = { new Assign(), new WriteLine()} }; designer.Load(root); Grid.SetColumn(designer.View, 0); // Create ExpressionEditorService this.expressionEditorService = new MyEditorService(); designer.Context.Services.Publish<IExpressionEditorService>(this.expressionEditorService); MyGrid.Children.Add(designer.View); }
You can test out Eric’s app using some of the many keyboard shortcuts associated with IntelliSense commands. For example, Ctrl+J invokes IntelliSense, Ctrl+K, I invokes QuickInfo, etc. Thanks Eric for sharing this out.