wpf-devexpress-dot-xpf-dot-layoutcontrol-dot-layoutcontrol-1990d63e.md
Allows you to save custom properties of layout groups and their children when saving layouts.
Namespace : DevExpress.Xpf.LayoutControl
Assembly : DevExpress.Xpf.LayoutControl.v25.2.dll
NuGet Package : DevExpress.Wpf.LayoutControl
public event EventHandler<LayoutControlWriteElementToXMLEventArgs> WriteElementToXML
Public Event WriteElementToXML As EventHandler(Of LayoutControlWriteElementToXMLEventArgs)
The WriteElementToXML event's data class is LayoutControlWriteElementToXMLEventArgs. The following properties provide information specific to this event:
| Property | Description |
|---|---|
| Element | Gets the layout element being written to a data store. |
| Xml | Gets an XMLWriter object that implements saving XML data. |
When saving/loading layouts to a data store, only properties that can be changed by an end-user during layout customization are stored/restored. If you need to save/load custom properties, handle the WriteElementToXML and LayoutControl.ReadElementFromXML events.
These events are useful if you allow users to change specific properties of layout items/groups, and want these changes to be saved/loaded when the layout is saved/loaded.
The following code shows how you can save/load the FontSize property for LayoutItem objects to a data store.
using DevExpress.Xpf.LayoutControl;
using DevExpress.Xpf.Core.Native;
private void layoutControl1_WriteElementToXML(object sender, DevExpress.Xpf.LayoutControl.LayoutControlWriteElementToXMLEventArgs e) {
if (typeof(LayoutItem).IsAssignableFrom(e.Element.GetType())) {
e.Element.WritePropertyToXML(e.Xml, LayoutItem.FontSizeProperty, "FontSize");
}
}
private void layoutControl1_ReadElementFromXML(object sender, DevExpress.Xpf.LayoutControl.LayoutControlReadElementFromXMLEventArgs e) {
if (typeof(LayoutItem).IsAssignableFrom(e.Element.GetType())) {
e.Element.ReadPropertyFromXML(e.Xml, LayoutItem.FontSizeProperty, "FontSize", typeof(double));
}
}
Note
WritePropertyToXML and ReadPropertyFromXML are extension methods declared in the DevExpress.Xpf.Core.Native namespace. To use these methods, ensure that this namespace is added to your unit.
See Also