Graphs can be saved and loaded into your application. The standard format used by yFiles is the GraphML format. GraphML is an XML format that can save graph structure, styles, and custom data.
Input and output work out-of-the-box for built-in graph elements and styles. To load or save custom data and styles, you may need to enhance the I/O process.
I/O functionality is enabled by default for programmatic use. Interactive use has to be enabled separately.
Before you can interactively save or load a graph using the default keyboard commands, file operations must be enabled on the graph control. This is done by setting
FileOperationsEnabled to true:
The current graph can be saved by the graph control and loaded into the graph control using the following methods:
Table 3.49. Saving and Loading a Graph
|SaveFile||Possibly opens a file dialog that lets the user choose where to save the graph. Saves the graph to the last known location or the chosen file.|
|SaveFileAs||Opens a file dialog and saves the graph to the selected file.|
|OpenFile||Shows an open file dialog and loads the chosen file.|
Once file operations have been enabled on the graph control, the following commands can be used:
Table 3.50. File Operation Commands
|Save||Possibly opens a file dialog that lets the user choose where to save the graph. Saves the graph to the last known location or the chosen file.|
|SaveAs||Opens a file dialog and saves the graph to the selected file.|
|Open||Shows an open file dialog and loads the chosen file.|
For a thorough explanation of working with GraphMLIOHandler, see the section called “Reading and Writing Graph Structure Data Using GraphML” and the yFiles for Silverlight tutorial, especially step 13.
Copyright ©2004-2015, yWorks GmbH. All rights reserved.