Search
DiagramBase.SerializeControl Event
See Also
 





Lets you save the attributes of controls hosted inside ControlNodes.

Namespace: MindFusion.Diagramming.Wpf
Assembly: MindFusion.Diagramming.Wpf

 Syntax

C#  Copy Code

public event EventHandler<ControlNodeEventArgs> SerializeControl

Visual Basic  Copy Code

Public Event SerializeControl As EventHandler(Of ControlNodeEventArgs)

 Event Data

SerializeControl event handlers receive an argument of type ControlNodeEventArgs.

 Remarks

By default the diagram component saves and loads hosted controls by means of the XamlWriter and XamlReader classes provided by the WPF framework. If they cannot serialize the content of nodes automatically, the SerializeControl and DeserializeControl events can be handled to implement custom serialization.

 Example

C#  Copy Code

private void OnDiagramSerializeControl(object sender, ControlNodeEventArgs e)
{
    TextBox control = e.Node.Control as TextBox;
    e.Handled = true;
    e.Context.WriteString(control.Text, "Text", e.XmlElement);
}

private void OnDiagramDeserializeControl(object sender, ControlNodeEventArgs e)
{
    e.Handled = true;
    string text = e.Context.ReadString("Text", e.XmlElement);
    e.Node.Control = new TextBox() { Text = text};
}

 See Also