如下面所示,AddDesigner 函数把设计器加到你的窗口中。
(代码段- Introduction to WF4 Lab – AddDesigner method CSharp)
private void AddDesigner()
{
//Create an instance of WorkflowDesigner class
this.workflowDesigner = new WorkflowDesigner();
//Place the WorkflowDesigner in the middle column of the grid
Grid.SetColumn(this.workflowDesigner.View, 1);
// Flush the workflow when the model changes
workflowDesigner.ModelChanged += (s, e) =>
{
workflowDesigner.Flush();
textXAML.Text = workflowDesigner.Text;
};
//Load a new Sequence as default.
this.workflowDesigner.Load(new Sequence());
//Add the WorkflowDesigner to the grid
grid1.Children.Add(this.workflowDesigner.View);
// Add the Property Inspector
Grid.SetColumn(workflowDesigner.PropertyInspectorView, 2);
grid1.Children.Add(workflowDesigner.PropertyInspectorView);
// Add the toolbox
ToolboxControl tc = CreateToolboxControl();
Grid.SetColumn(tc, 0);
grid1.Children.Add(tc);
}
{
//Create an instance of WorkflowDesigner class
this.workflowDesigner = new WorkflowDesigner();
//Place the WorkflowDesigner in the middle column of the grid
Grid.SetColumn(this.workflowDesigner.View, 1);
// Flush the workflow when the model changes
workflowDesigner.ModelChanged += (s, e) =>
{
workflowDesigner.Flush();
textXAML.Text = workflowDesigner.Text;
};
//Load a new Sequence as default.
this.workflowDesigner.Load(new Sequence());
//Add the WorkflowDesigner to the grid
grid1.Children.Add(this.workflowDesigner.View);
// Add the Property Inspector
Grid.SetColumn(workflowDesigner.PropertyInspectorView, 2);
grid1.Children.Add(workflowDesigner.PropertyInspectorView);
// Add the toolbox
ToolboxControl tc = CreateToolboxControl();
Grid.SetColumn(tc, 0);
grid1.Children.Add(tc);
}
(代码段- Introduction to WF4 Lab – AddDesigner method VB)
Private Sub AddDesigner()
'Create an instance of WorkflowDesigner class
workflowDesigner = New WorkflowDesigner()
'Place the WorkflowDesigner in the middle column of the grid
Grid.SetColumn(workflowDesigner.View, 1)
' Setup the Model Changed event handler
AddHandler workflowDesigner.ModelChanged,
Function(sender As Object, e As System.EventArgs)
' Flush the workflow when the model changes
workflowDesigner.Flush()
textXAML.Text = workflowDesigner.Text
Return Nothing
End Function
'Load a new Sequence as default.
workflowDesigner.Load(New Sequence())
'Add the WorkflowDesigner to the grid
grid1.Children.Add(workflowDesigner.View)
' Add the Property Inspector
Grid.SetColumn(workflowDesigner.PropertyInspectorView, 2)
grid1.Children.Add(workflowDesigner.PropertyInspectorView)
' Add the toolbox
Dim tc As ToolboxControl = CreateToolboxControl()
Grid.SetColumn(tc, 0)
grid1.Children.Add(tc)
End Sub
'Create an instance of WorkflowDesigner class
workflowDesigner = New WorkflowDesigner()
'Place the WorkflowDesigner in the middle column of the grid
Grid.SetColumn(workflowDesigner.View, 1)
' Setup the Model Changed event handler
AddHandler workflowDesigner.ModelChanged,
Function(sender As Object, e As System.EventArgs)
' Flush the workflow when the model changes
workflowDesigner.Flush()
textXAML.Text = workflowDesigner.Text
Return Nothing
End Function
'Load a new Sequence as default.
workflowDesigner.Load(New Sequence())
'Add the WorkflowDesigner to the grid
grid1.Children.Add(workflowDesigner.View)
' Add the Property Inspector
Grid.SetColumn(workflowDesigner.PropertyInspectorView, 2)
grid1.Children.Add(workflowDesigner.PropertyInspectorView)
' Add the toolbox
Dim tc As ToolboxControl = CreateToolboxControl()
Grid.SetColumn(tc, 0)
grid1.Children.Add(tc)
End Sub
在构造函数中,以上的那些函数会被调用。
(代码段- Introduction to WF4 Lab – MainWindow method CSharp)
public MainWindow()
{
InitializeComponent();
RegisterMetadata();
AddDesigner();
}
{
InitializeComponent();
RegisterMetadata();
AddDesigner();
}
(代码段- Introduction to WF4 Lab – MainWindow method VB)
Public Sub New()
' This call is required by the designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
RegisterMetadata()
AddDesigner()
End Sub
' This call is required by the designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
RegisterMetadata()
AddDesigner()
End Sub