A newer version of this page is available. Switch to the current version.

GridSerializationOptions Class

Contains options that specify how column specific settings are stored to and restored from a stream or file in XML format.

Namespace: DevExpress.Xpf.Grid

Assembly: DevExpress.Xpf.Grid.v20.2.dll


public class GridSerializationOptions :


The GridSerializationOptions provides two options: DataControlSerializationOptions.AddNewColumns and DataControlSerializationOptions.RemoveOldColumns. The first option specifies whether the columns that currently exist in the grid, but do not exist in a layout when it’s restored, should be retained. The second option specifies whether the columns that exist in a layout when it is restored but don’t currently exist in the grid, should be discarded.

To save the grid layout, use the DataControlBase.SaveLayoutToStream or DataControlBase.SaveLayoutToXml method. To load the layout, use the DataControlBase.RestoreLayoutFromStream or DataControlBase.RestoreLayoutFromXml method.

To learn more, see Saving and Restoring Layout.


To correctly save and restore the grid layout, grid columns should be uniquely identified using the x:Name attribute.


This example shows how to save the grid layout to a memory stream. To do this, click the ‘Save Layout’ button. Once saved, the grid layout can then be restored by clicking the ‘Restore Layout’ button.

View Example

<UserControl x:Class="DXGrid_GridLayout.MainPage"
    d:DesignHeight="300" d:DesignWidth="400"
    xmlns:local="clr-namespace:DXGrid_GridLayout" >

            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />
        <dxg:GridControl x:Name="grid" dx:DXSerializer.SerializationID="grid" 
                <dxg:GridColumn x:Name="colIssueName" FieldName="IssueName" />
                <dxg:GridColumn x:Name="colIssueType" FieldName="IssueType" />
                <dxg:GridColumn x:Name="colPrivate" FieldName="IsPrivate">Private</dxg:GridColumn>
                <dxg:TableView AutoWidth="True" />

        <StackPanel Grid.Row="1" Orientation="Vertical">
            <StackPanel Orientation="Horizontal">
                <Button Margin="1" Click="Button_Click">AddNewColumn</Button>
            <StackPanel Orientation="Horizontal">
                <Button Margin="1" Click="SaveButton_Click">Save Layout</Button>
                <Button x:Name="restoreButton" Margin="1" 
                        Click="LoadButton_Click" IsEnabled="{Binding IsLayoutSaved}">
                        Restore Layout
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.IO;

namespace DXGrid_GridLayout {
    public partial class MainPage : UserControl {
        public static readonly DependencyProperty IsLayoutSavedProperty =
            DependencyProperty.Register("IsLayoutSaved", typeof(bool), typeof(MainPage), null);
        public bool IsLayoutSaved {
            get { return (bool)GetValue(IsLayoutSavedProperty); }
            set { SetValue(IsLayoutSavedProperty, value); }
        MemoryStream layoutStream;
        public MainPage() {
            DataContext = this;
            IsLayoutSaved = false;
            grid.ItemsSource = IssueList.GetData();

        private void SaveButton_Click(object sender, RoutedEventArgs e) {
            layoutStream = new MemoryStream();
            IsLayoutSaved = true;
        private void LoadButton_Click(object sender, RoutedEventArgs e) {
            layoutStream.Position = 0;
        private void Button_Click(object sender, RoutedEventArgs e) {
            grid.Columns.Add(new DevExpress.Xpf.Grid.GridColumn() { FieldName = "IsPrivate" });
    public class IssueList {
        static public List<IssueDataObject> GetData() {
            List<IssueDataObject> data = new List<IssueDataObject>();
            data.Add(new IssueDataObject() {
                IssueName = "Transaction History",
                IssueType = "Bug", IsPrivate = true
            data.Add(new IssueDataObject() {
                IssueName = "Ledger: Inconsistency",
                IssueType = "Bug", IsPrivate = false
            data.Add(new IssueDataObject() {
                IssueName = "Data Import",
                IssueType = "Request", IsPrivate = false
            data.Add(new IssueDataObject() {
                IssueName = "Data Archiving",
                IssueType = "Request", IsPrivate = true
            return data;

    public class IssueDataObject {
        public string IssueName { get; set; }
        public string IssueType { get; set; }
        public bool IsPrivate { get; set; }


See Also