//AddNode method
private Node addNode(double offsetx, double offsety, Shapes shape, String label, double width, double height)
{
Node node = new Node();
node.OffsetX = offsetx;
node.OffsetY = offsety;
node.Shape = shape;
TextBox b = new TextBox();
b.Text = label;
node.Content = b;
node.HorizontalContentAlignment = HorizontalAlignment.Center;
node.VerticalContentAlignment = VerticalAlignment.Center;
(node.Content as TextBox).IsHitTestVisible = true;
node.Width = width;
node.Height = height;
model.Nodes.Add(node);
return node;
} |
<syncfusion:DiagramControl Name="diagramControl" IsSymbolPaletteEnabled="False"> <syncfusion:DiagramControl.Model> <syncfusion:DiagramModel x:Name="diagramModel"> <syncfusion:DiagramModel.Nodes> <syncfusion:Node Width="200" Height="70" Shape="FlowChart_Card"> <syncfusion:Node.Content> <Button Content="Click Me!"></Button> </syncfusion:Node.Content> </syncfusion:Node> </syncfusion:DiagramModel.Nodes> </syncfusion:DiagramModel> </syncfusion:DiagramControl.Model> <syncfusion:DiagramControl.View> <syncfusion:DiagramView IsZoomEnabled="True" Bounds="0,0,1200,1200" Name="diagramView"> </syncfusion:DiagramView> </syncfusion:DiagramControl.View> </syncfusion:DiagramControl>
//Hook the loaded event
diagramControl.Loaded += diagramControl_Loaded;
private void diagramControl_Loaded(object sender, RoutedEventArgs e)
{
foreach (Node node in diagrammodel.Nodes)
{
(node.Content as TextBox).IsHitTestVisible = true;
}
}
|