DashboardControl.SetInitialDashboardState Event

Allows you to specify the initial dashboard state when loading a dashboard.

Namespace: DevExpress.DashboardWpf

Assembly: DevExpress.Dashboard.v21.1.Wpf.dll

Declaration

public event SetInitialDashboardStateWpfEventHandler SetInitialDashboardState

Event Data

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

Property Description
Dashboard A dashboard whose state can be initialized. Inherited from SetInitialDashboardStateBaseEventArgs.
InitialState Gets or sets the dashboard initial state. Inherited from SetInitialDashboardStateBaseEventArgs.

Remarks

View Example: How to Set the Initial Dashboard State

This example demonstrates how to manage dashboard state to save and restore selected master filters values, current drill-down levels, and other parameters such as Treemap layers.

When the application starts, the DashboardControl loads the dashboard and the DashboardState object is deserialized and restored using the GetDataFromString method in the DashboardControl.SetInitialDashboardState event handler.

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

namespace WpfDashboard_DashboardState
{
    public partial class MainWindow : Window
    {
        public static readonly string PropertyName = "DashboardState";

        public MainWindow()
        {
            InitializeComponent();
        }

        DashboardState GetDataFromString(string customPropertyValue){
            DashboardState dState = new DashboardState();
            if(!string.IsNullOrEmpty(customPropertyValue)) {
                var xmlStateEl = XDocument.Parse(customPropertyValue);
                dState.LoadFromXml(xmlStateEl);
            }
            return dState;
        }

        private void dashboardControl_SetInitialDashboardState(object sender, DevExpress.DashboardWpf.SetInitialDashboardStateWpfEventArgs e){
            var state = GetDataFromString(dashboardControl.Dashboard.CustomProperties.GetValue(PropertyName));
            e.InitialState = state;
        }
     }
}       
//...

For more information about a dashboard state, refer to the Manage Dashboard State document.

See Also