dashboard-devexpress-dot-dashboardwpf-dot-dashboardcontrol-6bfb4270.md
Allows you to specify the initial dashboard state when loading a dashboard.
Namespace : DevExpress.DashboardWpf
Assembly : DevExpress.Dashboard.v25.2.Wpf.dll
NuGet Package : DevExpress.Wpf.Dashboard
public event SetInitialDashboardStateWpfEventHandler SetInitialDashboardState
Public Event SetInitialDashboardState As SetInitialDashboardStateWpfEventHandler
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. |
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;
}
}
}
//...
Imports DevExpress.DashboardCommon
Imports System
Imports System.Windows
Imports System.Xml.Linq
Namespace WpfDashboard_DashboardState
Partial Public Class MainWindow
Inherits Window
Public Shared ReadOnly PropertyName As String = "DashboardState"
Public Sub New()
InitializeComponent()
End Sub
Private Function GetDataFromString(ByVal customPropertyValue As String) As DashboardState
Dim dState As New DashboardState()
If (Not String.IsNullOrEmpty(customPropertyValue)) Then
Dim xmlStateEl = XDocument.Parse(customPropertyValue)
dState.LoadFromXml(xmlStateEl)
End If
Return dState
End Function
Private Sub dashboardControl_SetInitialDashboardState(ByVal sender As Object, ByVal e As DevExpress.DashboardWpf.SetInitialDashboardStateWpfEventArgs)
Dim state = GetDataFromString(dashboardControl.Dashboard.CustomProperties.GetValue(PropertyName))
e.InitialState = state
End Sub
End Class
End Namespace
'...
For more information about a dashboard state, refer to the Manage Dashboard State document.
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the SetInitialDashboardState event.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.
wpf-dashboard-how-to-set-initial-dashboard-state/CS/WpfDashboard_DashboardState/MainWindow.xaml#L20
DashboardSource="SampleDashboardWithState.xml"
SetInitialDashboardState="dashboardControl_SetInitialDashboardState"/>
</Grid>
#line 20 "..\..\..\MainWindow.xaml"
this.dashboardControl.SetInitialDashboardState += new DevExpress.DashboardWpf.SetInitialDashboardStateWpfEventHandler(this.dashboardControl_SetInitialDashboardState);
#ExternalSource("..\..\..\MainWindow.xaml",20)
AddHandler Me.dashboardControl.SetInitialDashboardState, New DevExpress.DashboardWpf.SetInitialDashboardStateWpfEventHandler(AddressOf Me.dashboardControl_SetInitialDashboardState)
See Also
SetDashboardState(DashboardState)