Save and Restore Layout
- 2 minutes to read
A Layout Control’s layout contains settings which determine how its visual elements behave, their size, position within the control, etc. A layout can be saved to a stream, XML file or system registry, and then applied to any other Layout Control. This allows you to customize a layout control just once, and then apply the saved settings to other layout controls in other applications.
The layout can also be temporarily saved to random-access memory (RAM) using the LayoutControl.SetDefaultLayout method. It can then be restored by clicking the Reset Layout menu item in the Layout Context Menu.
There are a number of options controlling saving of and restoring layouts. These options are accessible via the LayoutControl.OptionsSerialization object.
For layout items created at runtime, you need to initialize their Name properties with unique values, to allow the Layout Control’s layout to be correctly saved and restored. You also need to assign unique values to the Name properties of the controls that will be displayed within layout items.
When creating localizable applications that support multiple cultures, you may encounter a situation of losing localized captions after restoring a layout from a data store. This happens if the current locale differs from the locale that had been applied when the layout was saved. To resolve the issue (to not restore item captions while restoring the layout), set the LayoutSerializationOptions.RestoreLayoutItemText option to false.
- How to: Save and restore layout
- How to: Save the layout between application runs
- How to: Implement custom functionality for layout context menu