Manage Dashboard State

  • 3 min to read

A dashboard state describes the changes resulting from end-user interaction. The dashboard state is the DashboardState class instance and can contain the following objects:

Dashboard State Object


Selected master filter values for dashboard items.


Current drill-down levels for dashboard items.


Selected Range Filter interval.


Selected dashboard item layers for the following items:


A selected tab page.


Dashboard parameter values.


Use the DashboardState.Items property to get access to the dashboard item state collection.

The DashboardControl provides the following API to manage the dashboard state:

Member Description
GetDashboardState() Gets the current dashboard state.
SetDashboardState(DashboardState) Applies the dashboard state to the loaded dashboard.
SetInitialDashboardState Allows you to specify the initial dashboard state when loading a dashboard.


This example demonstrates how to manage the dashboard state to save and restore selected master filter values, current drill-down levels and other selections such as the selected Treemap layer.

When the main window closes, the GetDashboardState() method obtains a dashboard state object. It is serialized to XML and added to the XElement object stored in the Dashboard.UserData property. Subsequently, the dashboard with the dashboard state data is saved to a file.

When the application starts, the DashboardControl loads the dashboard and the DashboardState object is deserialized in the DashboardLoaded event handler.

The dashboard state is restored using the SetDashboardState(DashboardState) in the SetInitialDashboardState event handler.


The complete sample project How to Set the Initial Dashboard State is available in the DevExpress Examples repository.

using DevExpress.DashboardCommon;
using DevExpress.DashboardWpf;
using System;
using System.Windows;
using System.Xml.Linq;

namespace WpfDashboard_DashboardState {
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window {
        DashboardState dState = new DashboardState(); 
        public MainWindow() {
        private void dashboardControl_DashboardLoaded(object sender, DashboardLoadedEventArgs e) {
            XElement data = e.Dashboard.UserData;
            if (data != null) {
                if (data.Element("DashboardState") != null) {
                    XDocument dStateDocument = XDocument.Parse(data.Element("DashboardState").Value);
        private void dashboardControl_SetInitialDashboardState(object sender, SetInitialDashboardStateWpfEventArgs e) {
            e.InitialState = dState;
        private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) {
            dState = dashboardControl.GetDashboardState();
            XElement userData = new XElement("Root", 
                new XElement("DateModified", DateTime.Now), 
                new XElement("DashboardState", dState.SaveToXml().ToString(SaveOptions.DisableFormatting)));
            dashboardControl.Dashboard.UserData = userData;