Skip to content

Integrate WPF Blockly to your application

Huajiang Wei edited this page Nov 5, 2021 · 1 revision

Integrate WPF-Blockly to your application


  1. Define your script class, which must implement the "Class" interface. Add your script related information to the script class. Using the load and save function in Serialization, you can achieve the loading and saving your script.

  2. Add GraphicScriptEditor into your GUI

<editor:GraphicScriptEditor Name="Editor"/>
  1. Define your own expression, statement, function and event, and all these types to the toolbar
            List<ScriptStepGroup> toolbar = new List<ScriptStepGroup>();
            toolbar.Add(new ScriptStepGroup()
            {
                Name = "comment",
                Types = new List<object>() {
                    new Label(){Content="comment"},
                    new ScriptStep(new CommentStatement()),
                    new ScriptStep(new CommentStatement(){AllowMultiLine=true })
                }
            });
            Editor.SetToolBar(toolbar);
  1. Hanle the library import event. When user click the '+/-' button, this event will be raised. You can write your own library functions.
public event EventHandler<EventArgs> ChangeImportLibrary;

Please the check the demo application, and how to realize the library and use it.

  1. In the visual script, there are three types of AST (abstract syntax tree) node, they are expression, statement and function. Based on these three types, you can define your own script node.
Clone this wiki locally