Skip to main content
A newer version of this page is available. .

PivotGridControl.LayoutUpgrade Event

Occurs when a layout is restored from a data store (stream, XML file or system registry) and its version is different than the control’s current layout version.

Namespace: DevExpress.Xpf.PivotGrid

Assembly: DevExpress.Xpf.PivotGrid.v19.2.dll

Declaration

public event PivotLayoutUpgradeEventHandler LayoutUpgrade

Event Data

The LayoutUpgrade event's data class is PivotLayoutUpgradeEventArgs. The following properties provide information specific to this event:

Property Description
Handled Gets or sets a value that indicates the present state of the event handling for a routed event as it travels the route. Inherited from RoutedEventArgs.
OriginalSource Gets the original reporting source as determined by pure hit testing, before any possible Source adjustment by a parent class. Inherited from RoutedEventArgs.
PreviousVersion Returns the textual representation of the previous layout version.
RoutedEvent Gets or sets the RoutedEvent associated with this RoutedEventArgs instance. Inherited from RoutedEventArgs.
Source Gets or sets a reference to the object that raised the event. Inherited from RoutedEventArgs.

The event data class exposes the following methods:

Method Description
InvokeEventHandler(Delegate, Object) When overridden in a derived class, provides a way to invoke event handlers in a type-specific way, which can increase efficiency over the base implementation. Inherited from RoutedEventArgs.
OnSetSource(Object) When overridden in a derived class, provides a notification callback entry point whenever the value of the Source property of an instance changes. Inherited from RoutedEventArgs.

Remarks

The LayoutUpgrade event allows you to customize a saved layout after an older version of the layout is loaded from a data store (stream, XML file, system registry). This event is raised when a control’s LayoutVersion property is changed and allows you to determine which properties should be updated when you upgrade the layout’s version.

Use the DXSerializer.LayoutVersion property or DXSerializer.SetLayoutVersion method to assign different versions to different layouts.

The following code snippet demonstrates how to handle the LayoutUpgrade event that updates the Pivot Grid’s previous layout to v2.0 and replaces the “oldField” with another “newField”.

<dxpg:PivotGridControl x:Name="newVersionPivotGrid" Grid.Row="2"  
                        DataSource="{Binding PivotData}"
                        dx:DXSerializer.LayoutVersion="2.0"
                        dxpg:PivotSerializationOptions.RemoveOldFields="False"
                        dxpg:PivotSerializationOptions.StoreLayoutMode="AllOptions"
                        LayoutUpgrade="newVersionPivotGrid_LayoutUpgrade"
                        >
</dxpg:PivotGridControl>
<dxpg:PivotGridControl x:Name="oldVersionPivotGrid" Grid.Row="2" Grid.Column="1" 
                        DataSource="{Binding PivotData}"
                        dx:DXSerializer.LayoutVersion="1.0"
                        LayoutUpgrade="newVersionPivotGrid_LayoutUpgrade"
                        dxpg:PivotSerializationOptions.RemoveOldFields="False"
                        dxpg:PivotSerializationOptions.StoreLayoutMode="AllOptions"
                        >
</dxpg:PivotGridControl>
private void newVersionPivotGrid_LayoutUpgrade(object sender, PivotLayoutUpgradeEventArgs e)
{
    if(e.PreviousVersion == "1.0")
    {
        //Remove the obsolete field.
        var oldField = newVersionPivotGrid.Fields["oldField"];
        newVersionPivotGrid.Fields.Remove(oldField);
        //Add the new field.
        var newField = new PivotGridField() {
            FieldName = "newField",
            Caption="New Value Field",
            Name = "newValueField",
            Area = FieldArea.DataArea
        };
        newVersionPivotGrid.Fields.Add(newField);
    }
}
See Also